---
# System prepended metadata

title: Flask on Heroku

---

# Flask on Heroku

### Remember to setup buildpack
- Heroku Dashboard -> Settings -> Buildpacks
- `requirements.txt` is required in your project (otherwise, deployment will failed)：better to use pipenv: `pipenv lock --requirements > requirements.txt`


### Webserver
- `gunicorn` recommended： `pipenv install gunicorn`
> note: run gunicorn locally: `pipenv run gunicorn #{your_app_name}:app`

- Create a file called `Procfile` on the root path in your project
- Add the following contents to Procfile:
```
web: gunicorn main:app
```
> What will Procfile do?
> Heroku apps include a Procfile that specifies the commands that are executed by the app on startup.
> A Procfile declares its process types on individual lines, each with the following format:
> ```
> <process type>: <command>
> ```
- Don't forget to scale up dynos: `heroku ps:scale web=1`

### Deploy
```
git push heroku master
```