Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

merging with main #39

Merged
merged 49 commits into from
Jan 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
49 commits
Select commit Hold shift + click to select a range
092198a
"Languages", "Libraries" and "Star History" sections added
DogukanUrker Jan 18, 2024
88d8efa
Update README.md
DogukanUrker Jan 18, 2024
5ec6073
Create GitHubBanner.png
DogukanUrker Jan 18, 2024
d28c7ca
Create LogoSmall.png
DogukanUrker Jan 18, 2024
72f4dba
Create LogoNormal.png
DogukanUrker Jan 18, 2024
37dc348
Create Icon180.ico
DogukanUrker Jan 18, 2024
5fe21dc
Update Icon180.ico
DogukanUrker Jan 18, 2024
bee52de
app tab icon changed
DogukanUrker Jan 18, 2024
8afe7a3
added app icon
DogukanUrker Jan 18, 2024
c8e8c7f
Update README.md
DogukanUrker Jan 18, 2024
319e40e
RECAPTCHA Verification added to app
DogukanUrker Jan 18, 2024
39b9d56
RECAPTCHA Verification added to user sign up page
DogukanUrker Jan 18, 2024
1e50658
better frontend code for recaptcha
DogukanUrker Jan 18, 2024
5736ae2
tab icon source changed
DogukanUrker Jan 18, 2024
8a63505
Update GitHubBanner.png
DogukanUrker Jan 18, 2024
69f7049
Update GitHubBanner.png
DogukanUrker Jan 18, 2024
acb1e59
logo changes
DogukanUrker Jan 18, 2024
d0076e3
typo fix in comments
DogukanUrker Jan 18, 2024
ed0df6f
Update signup.py
DogukanUrker Jan 18, 2024
112e5f5
Custom 401 error page added
DogukanUrker Jan 18, 2024
fa6b9c3
Update app.py
DogukanUrker Jan 18, 2024
07db827
removed unnecessary code
DogukanUrker Jan 18, 2024
fbe9feb
Update signup.py
DogukanUrker Jan 18, 2024
e6029d5
recaptcha added to login page
DogukanUrker Jan 18, 2024
f4fbb51
RECAPTCHA setting for per form
DogukanUrker Jan 18, 2024
1af529c
Update login.py
DogukanUrker Jan 18, 2024
1e98a6c
Update signup.py
DogukanUrker Jan 18, 2024
c963306
Update app.py
DogukanUrker Jan 18, 2024
e8db058
cleaner text view for terminal messages and log.log messages
DogukanUrker Jan 18, 2024
a268fb3
Update login.py
DogukanUrker Jan 18, 2024
316393e
Update login.py
DogukanUrker Jan 18, 2024
6e4ce85
Update login.py
DogukanUrker Jan 18, 2024
c8e27b4
module version updates [Flask, WTForms]
DogukanUrker Jan 18, 2024
09526f2
RECAPTCHA Verification added to 'account settings'
DogukanUrker Jan 19, 2024
fbb48a7
RECAPTCHA Verification added to 'post edit'
DogukanUrker Jan 19, 2024
1f87645
RECAPTCHA Verification added to 'post create'
DogukanUrker Jan 19, 2024
274c4ec
Update helpers.py
DogukanUrker Jan 19, 2024
f6be560
Update constants.py
DogukanUrker Jan 19, 2024
62c6e24
RECAPTCHA Verification added to 'change profile picture'
DogukanUrker Jan 19, 2024
0fc2336
RECAPTCHA Verification added to 'change username'
DogukanUrker Jan 19, 2024
547a557
RECAPTCHA Verification added to 'verify user'
DogukanUrker Jan 19, 2024
bada52b
RECAPTCHA Verification added to 'password reset'
DogukanUrker Jan 19, 2024
ee5ecab
RECAPTCHA Verification added to 'password change'
DogukanUrker Jan 19, 2024
750067a
RECAPTCHA Verification added to 'user dashboard'
DogukanUrker Jan 20, 2024
f17962c
Update dashboard.py
DogukanUrker Jan 20, 2024
59eb216
Update dashboard.html
DogukanUrker Jan 20, 2024
cc35721
Update dashboard.html
DogukanUrker Jan 20, 2024
9555ce2
Safer way to changing user roles
DogukanUrker Jan 20, 2024
4657a17
added comment
DogukanUrker Jan 20, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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