Features:
- Uses Flask
- Uses Flask REST Plus to build REST API
- (optional) Uses Docker
- (optional) Heroku app (Docker workflow)
If you need some environment variables set, use .env file.
For example ifwe are going to use AWS S3.
Create .env file with the following contents:
AWS_ACCESS_KEY_ID=
AWS_SECRET_ACCESS_KEY=
S3_BUCKET=
It is always a good idea to create a virtual environment
python3 -m venv venvIt will create a venv directory with isolated copy of Python
To activate the created virtual environment run
source venv/bin/activateAfter virtual environment activation we don't need to use python3 and pip3, we can normally use python and pip
Update pip
pip install --upgrade pipInstall dependencies For deployment.
pip install -r requirements.txtDevelopment server
python web/app.py --debugOpen browser at the address shown.
The debug options force the server automatically reload the app if any sources are changed.
Alternatively run via gunicorn (as it run on Heroku)
cd web
gunicorn --bind 0.0.0.0:5000 app:appdocker build -t appname:latest .docker run -t -i --env-file .env -p 5000:5000 -e PORT=5000 appname:latestOption 1. Locally build docker image and push it to Heroku
heroku container:push web --app herokuappname
heroku container:release web --app herokuappnameOption 2. Remotely build on Heroku
git push heroku master