This is a boilerplate for a PostgreSQL Flask app that can run as a local poetry-based, Heroku or Docker application. Requires python 3.7 or higher.
- Install Poetry if you don't have it using
pip install poetry- On WSL install using the get-poetry route. For example, on Ubuntu, do
curl -sSL https://raw.githubusercontent.com/python-poetry/poetry/master/get-poetry.py | python3 -.
- On WSL install using the get-poetry route. For example, on Ubuntu, do
- Install the packages:
poetry install - To open a Quart shell, just do
poetry run flask shell
- Run the first migration with
poetry run flask db upgrade- Subsequent migrations after models changes can be run with
poetry run flask db migrate -m "added app table field".
- Subsequent migrations after models changes can be run with
- To run the application do:
poetry run flask run - Open
http://localhost:5000on your browser
- Run tests by doing
poetry run pytest
- Make sure your folder is being shared within Docker client (Preferences > Resources > File Sharing)
- Run
docker-compose up --build. If there's a timeout error, you can restart the Quart container. - To do the first migration:
docker-compose run --rm web poetry run flask db upgrade
- Restart using docker-compose and head over to
http://localhost:5000on your browser - Run tests by doing
docker-compose run --rm web poetry run pytest -s - To connect to the Docker PostgreSQL shell, do
docker exec -it app_db_1 psql postgres -U app_user
- Use Hypercorn
hypercorn --bind 0.0.0.0:$PORT --reload wsgi:app
- Start the Codespace
- First time:
- Run
poetry install - Make sure to select the poetry Python interpreter for VSCode. If you don't see it, hit refresh on the dialog.
- Do the first migration:
poetry run flask db upgrade
- Run
- To run the application:
poetry run flask run- The codespace will give you a private URL for your application
- To connect to Postgres Database:
psql -h localhost -Uapp_user postgres