Skip to content

ondiekelijah/Threaded-Replies-using-Flask-SQLAlchemy-MySQL

Repository files navigation

Threaded comments using Common Table Expressions (CTE) for a MySQL Flask blog or CMS

Credits to miguelgrinberg & peterspython

Also read more about the implementation here or here

Set up & Installation.

1 .Clone/Fork the git repo and create an environment

Windows

git clone https://github.com/Dev-Elie/Threaded-Replies-using-Flask-SQLAlchemy-MySQL.git
cd Threaded-Replies-using-Flask-SQLAlchemy-MySQL
py -3 -m venv venv

macOS/Linux

git clone https://github.com/Dev-Elie/Threaded-Replies-using-Flask-SQLAlchemy-MySQL.git
cd Threaded-Replies-using-Flask-SQLAlchemy-MySQL
python3 -m venv venv

2 .Activate the environment

Windows

venv\Scripts\activate

macOS/Linux

. venv/bin/activate or source venv/bin/activate

3 .Install the requirements

Applies for windows/macOS/Linux

pip install -r requirements.txt

4 .Migrate/Create a database

Applies for windows/macOS/Linux
NB First create a MySQL database then execute then
create a .env file and paste the following lines of code;

SECRET_KEY = 'secret-key'
SQLALCHEMY_DATABASE_URI = "mysql+mysqlconnector://mysql-username:mysql-db-pass@localhost/db-name"
SQLALCHEMY_TRACK_MODIFICATIONS = True

Once done execute

python manage.py

5. Run the application

For linux and macOS Make the run file executable by running the code

chmod 777 run

Then start the application by executing the run file

./run

On windows

set FLASK_APP=main
flask run

During your experiment, you can manage your posts and comments from the Flask Admin panel. http://localhost:5000/admin/

sample query result


Follow me on Twitter

dev_elie

About

A Python Flask app with a MySQL database that implements a nested/threaded replies commenting engine. SQLAlchemy is used as the ORM.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published