#Book Review Platform
- Python 3.x
- PostgreSQL
- Clone the repository:
git clone [https://github.com/TheExecuter1/RBAC-Book-Review-Platform/tree/main] - Navigate to the project directory:
cd [project-directory] - Create a virtual environment:
python -m venv venv - Activate the virtual environment:
- On Windows:
venv\Scripts\activate - On Unix or MacOS:
source venv/bin/activate
- On Windows:
- Install required packages:
pip install -r requirements.txt
- Install PostgreSQL: [https://www.postgresql.org/download/]
- Create a new PostgreSQL database for the app.
- Update the app's configuration to connect to your PostgreSQL database:
- Open
app/__init__.py - Set the
SQLALCHEMY_DATABASE_URIto your database URI:SQLALCHEMY_DATABASE_URI = 'postgresql://username:password@localhost/dbname'
- Open
Initialize a migration directory:
flask db initThis command will add a migrations folder to your application, which will track all database migrations.
Open the migrations folder and go to alembic.ini Below the [alembic] put this line 'sqlalchemy.url = postgresql://username:password@localhost/dbname'
-
If you make changes to your database models, generate new migration scripts:
flask db migrate -m "Description of changes" -
Again, apply the new migrations to the database:
flask db upgrade
To set these up:
- Create a
.envfile in the root directory of the project. - Add the following environment variables to the
.envfile:SECRET_KEY=your_secret_key_here JWT_SECRET_KEY=your_jwt_secret_key_here - Replace
your_secret_key_hereandyour_jwt_secret_key_herewith your own secret keys.
You can generate a secret key in Python:
import os
print(os.urandom(16))
Run this script in a Python environment to generate a secure secret key.
- Run the Flask application:
flask run.py - Access the app in your web browser at
http://127.0.0.1:5000/