Skip to content

Commit

Permalink
Merge pull request #39 from DogukanUrker/main
Browse files Browse the repository at this point in the history
merging with main
  • Loading branch information
DogukanUrker authored Jan 20, 2024
2 parents 00d4c7e + 4657a17 commit f725e19
Show file tree
Hide file tree
Showing 54 changed files with 1,541 additions and 308 deletions.
52 changes: 48 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
# [flaskBlog📜](https://dogukanurker.com/flaskblog)
# [flaskBlog](https://dogukanurker.com/flaskblog) [<img src="https://raw.githubusercontent.com/DogukanUrker/flaskBlog/main/images/Icon180.ico" style='border-radius: 0.5rem; widht:60px; height: 60px;' />](https://dogukanurker.com/flaskblog)

**English** | [Türkçe](docs/readme_tr.md)

<img src="https://raw.githubusercontent.com/DogukanUrker/flaskBlog/main/images/GitHubBanner.png" style='border-radius: 0.5rem; widht:768px; height: 384px;' />

Simple blog app built with Flask.
<br/>
[Contact](mailto:[email protected])<br/>
Expand All @@ -18,6 +20,7 @@ Simple blog app built with Flask.

## Features 💫


| Feature | Status |
| :--------------------- | :----: |
| User Page ||
Expand Down Expand Up @@ -49,9 +52,7 @@ Simple blog app built with Flask.
| Custom Profile Picture ||
| User Verification ||

##

Requirements 📦
## Requirements 📦

- Flask
- Passlib
Expand All @@ -60,6 +61,45 @@ Requirements 📦
- Flaskwebgui <sub><sup>( if you run desktop.py )</sup></sub>
- Python 3.10 or newer

## Languages 🧑🏻‍💻

### Backend

- Python

### Frontend

- HTML
- CSS
- JavaScript

## Libraries 📚

### Backend

- OS
- SSL
- Socket
- Smtplib
- Secrets
- SQLite3
- Time
- Random
- DateTime
- Email
- Passlib
- Flask
- WTForms
- Flask_WTF
- FlaskWebGui <sub><sup>( if you run desktop.py )</sup></sub>

### Frontend

- jQuery
- TailwindCSS
- Tabler Icons
- Summer Note

## Installation ⬇️

download source code from Github 💾
Expand Down Expand Up @@ -101,3 +141,7 @@ Password: admin
### Support 💰

<a href="https://dogukanurker.com/donate" target="_blank"><img src="https://cdn.buymeacoffee.com/buttons/v2/arial-red.png" alt="Buy Me A Coffee" style="height: 60px !important;width: 217px !important;" ></a>

### Star History ✨

[![Star History Chart](https://api.star-history.com/svg?repos=dogukanurker/flaskblog&type=Date)](https://star-history.com/#dogukanurker/flaskblog&Date)
69 changes: 64 additions & 5 deletions app.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
from helpers import message

message(breaker=True)
message("3", "APP IS STARTING...")


Expand All @@ -23,7 +24,6 @@
from routes.verifyUser import verifyUserBlueprint
from routes.adminPanel import adminPanelBlueprint
from routes.createPost import createPostBlueprint
from routes.setUserRole import setUserRoleBlueprint
from routes.passwordReset import passwordResetBlueprint
from routes.changeUserName import changeUserNameBlueprint
from routes.changePassword import changePasswordBlueprint
Expand All @@ -41,16 +41,31 @@
LOG_IN,
APP_HOST,
APP_NAME,
APP_PORT,
DEBUG_MODE,
TAILWIND_UI,
REGISTRATION,
LOG_FILE_ROOT,
APP_ROOT_PATH,
APP_SECRET_KEY,
SESSION_PERMANENT,
APP_PORT,
)

from helpers import (
RECAPTCHA,
RECAPTCHA_LOGIN,
RECAPTCHA_COMMENT,
RECAPTCHA_SIGN_UP,
RECAPTCHA_SITE_KEY,
RECAPTCHA_POST_EDIT,
RECAPTCHA_SECRET_KEY,
RECAPTCHA_VERIFY_URL,
RECAPTCHA_VERIFY_USER,
RECAPTCHA_POST_CREATE,
RECAPTCHA_PASSWORD_RESET,
RECAPTCHA_PASSWORD_CHANGE,
RECAPTCHA_USERNAME_CHANGE,
RECAPTCHA_PROFILE_PICTURE_CHANGE,
)
from UISelector import TEMPLATE_FOLDER, STATIC_FOLDER

app = Flask(
Expand All @@ -64,6 +79,7 @@
app.config["SESSION_PERMANENT"] = SESSION_PERMANENT
csrf = CSRFProtect(app)

message(breaker=True)
message("1", f"APP DEBUG MODE: {DEBUG_MODE}")
message("3", f"APP NAME: {APP_NAME}")
message("3", f"APP HOST: {APP_HOST}")
Expand All @@ -74,8 +90,42 @@
message("3", f"LOG FILE ROOT: {LOG_FILE_ROOT}")
message("3", f"LOG IN: {LOG_IN}")
message("3", f"REGISTRATION: {REGISTRATION}")
message(breaker=True)


match RECAPTCHA:
case True:
match RECAPTCHA_SITE_KEY == "" or RECAPTCHA_SECRET_KEY == "":
case True:
message(
"1",
f"RECAPTCHA KEYS IS UNVALID THIS MAY CAUSE THE APPLICATION TO CRASH",
)
message(
"1",
f"PLEASE CHECK YOUR RECAPTCHA KEYS OR SET RECAPTCHA TO FALSE FROM TRUE IN 'constants.py'",
)
case False:
message("2", "RECAPTCHA IS ON")
message("3", f"RECAPTCHA RECAPTCHA_SITE_KEY KEY: {RECAPTCHA_SITE_KEY}")
message("3", f"RECAPTCHA SECRET KEY: {RECAPTCHA_SECRET_KEY}")
message("3", f"RECAPTCHA VERIFY URL: {RECAPTCHA_VERIFY_URL}")
message("6", f"RECAPTCHA LOGIN: {RECAPTCHA_LOGIN}")
message("6", f"RECAPTCHA SIGN UP: {RECAPTCHA_SIGN_UP }")
message("6", f"RECAPTCHA POST CREATE: {RECAPTCHA_POST_CREATE}")
message("6", f"RECAPTCHA POST EDIT: {RECAPTCHA_POST_EDIT }")
message("6", f"RECAPTCHA COMMENT: {RECAPTCHA_COMMENT}")
message("6", f"RECAPTCHA PASSWORD RESET: {RECAPTCHA_PASSWORD_RESET}")
message("6", f"RECAPTCHA PASSWORD CHANGE: {RECAPTCHA_PASSWORD_CHANGE}")
message("6", f"RECAPTCHA USERNAME CHANGE: {RECAPTCHA_USERNAME_CHANGE}")
message("6", f"RECAPTCHA VERIFY USER: {RECAPTCHA_VERIFY_USER}")
message(
"6",
f"RECAPTCHA PROFILE PICTURE CHANGE: {RECAPTCHA_PROFILE_PICTURE_CHANGE}",
)
case False:
message("1", f"RECAPTCHA IS OFF")
message(breaker=True)
match TAILWIND_UI:
case True:
message("4", f"UI MODE: TAILWIND-CSS")
Expand All @@ -85,10 +135,12 @@
message("4", f"TEMPLATE FOLDER: {TEMPLATE_FOLDER}")
message("4", f"STATIC FOLDER: {STATIC_FOLDER}")

message(breaker=True)
dbFolder()
usersTable()
postsTable()
commentsTable()
message(breaker=True)


@app.context_processor
Expand All @@ -102,8 +154,14 @@ def notFound(e):
return render_template("404.html"), 404


@app.errorhandler(401)
def unauthorized(e):
message("1", "401 UNAUTHORIZED ERROR")
return render_template("401.html"), 401


@app.errorhandler(CSRFError)
def handle_csrf_error(e):
def csrfError(e):
message("1", "CSRF ERROR")
return render_template("csrfError.html", reason=e.description), 400

Expand All @@ -121,7 +179,6 @@ def handle_csrf_error(e):
app.register_blueprint(adminPanelBlueprint)
app.register_blueprint(createPostBlueprint)
app.register_blueprint(verifyUserBlueprint)
app.register_blueprint(setUserRoleBlueprint)
app.register_blueprint(passwordResetBlueprint)
app.register_blueprint(changeUserNameBlueprint)
app.register_blueprint(changePasswordBlueprint)
Expand All @@ -136,5 +193,7 @@ def handle_csrf_error(e):
case "__main__":
message("2", "APP STARTED SUCCESSFULLY")
message("2", f"RUNNING ON http://{APP_HOST}:{APP_PORT}")
message(breaker=True)
app.run(debug=DEBUG_MODE, host=APP_HOST, port=APP_PORT)
message(breaker=True)
message("1", "APP SHUT DOWN")
49 changes: 47 additions & 2 deletions constants.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
from helpers import secrets, socket


### GENERAL APP SETTINGS ###
APP_NAME = "flaskblog" # NAME OF THE FLASK APP.
APP_ROOT_PATH = "." # THE PATH TO THE ROOT OF THE APP FILES.
APP_HOST = socket.gethostbyname(
Expand All @@ -11,9 +13,52 @@
LOG_IN = True # TURN ON/OFF USER LOG IN UP.
REGISTRATION = True # TURN ON/OFF USER SIGN UP.
LOG_FILE_ROOT = "log.log" # ROOT OF THE LOG FILE FROM WHERE MESSAGES ARE PRINTED FROM THE MESSAGE MODULE.
APP_SECRET_KEY = secrets.token_urlsafe(32) # FLASK APP'S SECRET KEY.
SESSION_PERMANENT = True # FLASK APP'S SESSIONS.
BREAKER_TEXT = "===================================================================================================="

### DATABASE SETTINGS ###
DB_FOLDER_ROOT = "db" # ROOT OF THE DATABASE FOLDER WHERE .db FILES ARE LOCATED.
DB_USERS_ROOT = DB_FOLDER_ROOT + "/users.db" # ROOT OF THE USERS DATABASE.
DB_POSTS_ROOT = DB_FOLDER_ROOT + "/posts.db" # ROOT OF THE POSTS DATABASE.
DB_COMMENTS_ROOT = DB_FOLDER_ROOT + "/comments.db" # ROOT OF THE COMMENTS DATABASE.
APP_SECRET_KEY = secrets.token_urlsafe(32) # FLASK APP'S SECRET KEY.
SESSION_PERMANENT = True # FLASK APP'S SESSIONS.


### RECAPTCHA SETTINGS ###
RECAPTCHA = False # TURN ON/OFF RECAPTCHA VERIFICATION. MORE INFO ABOUT RECAPTCHA: https://developers.google.com/recaptcha/docs/v3
RECAPTCHA_SITE_KEY = "" # RECAPTCHA SITE KEY. SIGN UP FOR API KEY PAIR: http://www.google.com/recaptcha/admin
RECAPTCHA_SECRET_KEY = "" # RECAPTCHA SECRET KEY. SIGN UP FOR API KEY PAIR: http://www.google.com/recaptcha/admin
RECAPTCHA_VERIFY_URL = "https://www.google.com/recaptcha/api/siteverify" # RECAPTCHA VERIFY URL. DO NOT NEED TO CHANGE THIS.

# IF RECAPTCHA = False, YOU DO NOT NEED TO CHANGE THESE VARIABLES:
RECAPTCHA_LOGIN = True # TURN ON/OFF RECAPTCHA VERIFICATION FOR "LOGIN" ACTION.
RECAPTCHA_SIGN_UP = True # TURN ON/OFF RECAPTCHA VERIFICATION FOR "SIGNUP" ACTION.
RECAPTCHA_POST_CREATE = (
True # TURN ON/OFF RECAPTCHA VERIFICATION FOR "CREATE POST" ACTION.
)
RECAPTCHA_POST_EDIT = True # TURN ON/OFF RECAPTCHA VERIFICATION FOR "EDIT POST" ACTION.
RECAPTCHA_POST_DELETE = (
True # TURN ON/OFF RECAPTCHA VERIFICATION FOR "DELETE POST" ACTION.
)
RECAPTCHA_COMMENT = True # TURN ON/OFF RECAPTCHA VERIFICATION FOR "COMMENT" ACTION.
RECAPTCHA_COMMENT_DELETE = (
True # TURN ON/OFF RECAPTCHA VERIFICATION FOR "DELETE COMMENT" ACTION.
)
RECAPTCHA_PASSWORD_RESET = (
True # TURN ON/OFF RECAPTCHA VERIFICATION FOR "PASSWORD RESET" ACTION.
)
RECAPTCHA_PASSWORD_CHANGE = (
True # TURN ON/OFF RECAPTCHA VERIFICATION FOR "PASSWORD CHANGE" ACTION.
)
RECAPTCHA_USERNAME_CHANGE = (
True # TURN ON/OFF RECAPTCHA VERIFICATION FOR "USERNAME CHANGE" ACTION.
)
RECAPTCHA_VERIFY_USER = (
True # TURN ON/OFF RECAPTCHA VERIFICATION FOR "VERIFY USER" ACTION.
)
RECAPTCHA_DELETE_USER = (
True # TURN ON/OFF RECAPTCHA VERIFICATION FOR "DELETE USER" ACTION.
)
RECAPTCHA_PROFILE_PICTURE_CHANGE = (
True # TURN ON/OFF RECAPTCHA VERIFICATION FOR "PROFILE PICTURE CHANGE" ACTION.
)
Loading

0 comments on commit f725e19

Please sign in to comment.