Make sure you have Python 3.7 installed locally. To push to Heroku, you'll need to install the Heroku CLI.
$ git clone https://github.com/openaq/openaq-snapshot.git
$ cd openaq-snapshot
$ pipenv install
$ pipenv shell
$ flask run
Your app should now be running on localhost:5000.
You can also install the dependencies without pipenv
:
$ python3 -m venv env
$ source ./env/bin/activate
$ pip install -r requirements.txt
After you update the Pipfile and Pipfile.lock files, update the requirements.txt
with:
$ pip freeze > requirements.txt
requirements.txt
is used for deploying to AWS Elastic Beanstalk.
Make sure you have pytest
installed.
$ pytest tests.py
Prerequisites: Python 3.7.9, pip, and awsebcli
You also need your AWS credentials ready in your ~/.aws/credentials
file.
When starting a new deployment, run:
eb init
The command will start an interactive session where you:
- Enter the app name
- Choose Python version to use
- Choose AWS region
This will create a new environment, and deploy the app there.
eb create env-name
Once deployed, open the app in a browser window:
eb open
You can set configuration values such as MAPBOX_ACCESS_TOKEN
using:
eb setenv KEY=value KEY2=value2
Here are some helpful commands to monitor your deployment:
# show health status of envs
eb health
# show logs
eb logs
# print environment variables
eb printenv
# shows environment status and info
eb status
$ heroku create
$ git push heroku master
$ heroku open
or
For more information about using Python on Heroku, see these Dev Center articles: