Welcome to the backend for official DSC HIT website.
This is a Python 3 and Flask based REST API which uses Firebase for datastore.
There are 2 steps to deploy.
- Create a Firebase project & generate keys for a Firebase Service Account.
- Save the credential file as
key.json
in your project root.
IMPORTANT Don't forget to addkey.json
to your.gitignore
file so you don't accidentally commit it. - Export the
key.json
contents through an environment variable depending on your development platform. For Linux I use direnv with a.envrc
file which looks something like the following
...
export FIREBASE_CERT=$(cat key.json)
...
- Setup Heroku on local machine.
- Setup Heroku config variables. These variables can be accessed using the Pyhton
os.environ
variable. For this project, create a config variable namedFIREBASE_CERT
and paste the contents of thekey.json
file as value. - If you have used Heroku dashboard to create the app then you need to setup git remote for Heroku.
- Finally, push the code to heroku remote and it will be deployed automatically.
- Create a virtual environment in project root
python3 -m venv venv
- Activate the
venv
source ./venv/bin/activate
- Install the dependencies using
pip
pip install -r requirements.txt
- [OPTIONAL] Export the environment variable
FLASK_ENV
# this line may also be added in .envrc file
export FLASK_ENV=development
- Run flask app
flask run