This Scaffold is a simple Flask application that uses the following technologies:
- Flask
- Flask-SQLAlchemy
- sqlite3
- Firebase (As authentication provider)
- daisyUI (Tailwind CSS Framework)
- Jinja2 (Template Engine)
- pipenv (Virtual Environment)
- Python 3.11.0
- Black (Code Formatter)
- Clone this repository
- Install pipenv
- create a virtual environment
- Install dependencies
under the root directory of the project run the following command:
pipenv install
- Run the application
# set the FLASK_APP environment variable
export FLASK_APP="app:create_app('development')"
# run the application
flask run
- Create a new model under the
app/models
directory - Use following command to create the table
# open the flask shell
flask shell
# create the tables
from app.extensions import db
from app.models.post import Post
db.create_all()
# exit the shell
exit()
- Create a new route under the
app/routes
directory - Create a blueprint as it is shown in the
app/routes/auth.py
file - Register the blueprint in the
app/__init__.py
file
- The .env file is used to store the environment variables
- The .env file should not be pushed to the repository
- The .env file should be added to the .gitignore file
- Following command shows how to generate SECRET_KEY in .env file
python -c 'import secrets; print(secrets.token_hex())'
You need to set up your Firebase Authentication Configurations under config/firebase
folder
You should build two new json files: firebaseAdminConfig.json
and firebaseConfig.json
- In the
firebaseAdminConfig.json
file you should add your Firebase Admin SDK configurations:
Export Admin SDK private key — Go to Project Overview -> Service Accounts -> Firebase Admin SDK, then select Python as the language and click generate new private key and your file will download. Do NOT share this file or upload it anywhere it allows total read and write access of your Firebase project. - In the
firebaseConfig.json
file you should add your Firebase SDK configurations:
Go to Project Overview -> Project Settings -> General -> Your apps -> Firebase SDK snippet -> Config and copy the config object and paste it in thefirebaseConfig.json
file.
Also you have to add your realtime database url to thefirebaseConfig.json
file since we use Pyrebase4 and the bug still not repaired.
You should add the url as"databaseURL": "your realtime database url"