This repo contains skeleton code for a barebone Flask app. The app can be ran via docker-compose too.
The pipenv
image is used. Since there's only a latest
tag, below I reference a specific image build.
docker-compose up
- Install pipenv
$ pipenv install
- pipenv will output the folder of the new interpreter
- In PyCharm, add a new interpreted and point to the folder from above + Scripts/pyhton
- To run the flask app (see below the Note for PyCharm users)
$ flask run
When running via PyCharm and assuming that pipenv is used, you need to select the correct Python interpreter.
$ pipenv shell
(some_app-tKuPD0ya) $ which python
/home/georgi/.local/share/virtualenvs/some_app-tKuPD0ya/bin/python
When creating a run configuration, select as "Module name" (the default is to execute a script) flask
and as Parameters run
. For older versions of the IDE, see this
Make sure to set the Working directory folder in the run config to the project folder.
Example for unittest
.
To run them via PyCharm
- You need the '.env_test' file placed in the repo root with the
SECRET_KEY
andFLASK_ENV=testing
env vars
FLASK_ENV=testing
SECRET_KEY=somesecret
- Create a new Python test run configuration with the
/tests
as the Path target and the root of the repo as a working directory