- clone
git clone https://github.com/tsadimas/flask-example-project.git
- create virtual environment, activate and install requirements
python3 -m venv fvenv
source fvenv/bin/activate
pip install -r requirements.txt
- run
python app/main.py
or
export FLASK_APP=app.main.py FLASK_DEBUG=1 TEMPLATES_AUTO_RELOAD=1; flask run -h 0.0.0.0 -p 8000
or
gunicorn app.main:app --bind 0.0.0.0:5000
SQLALCHEMY_DATABASE_URI=sqlite:///./students.sqlite3
SQLALCHEMY_DATABASE_URI=postgresql://demouser:[email protected]/demodb
SQLALCHEMY_DATABASE_URI: mysql://demo:demo@db01/demo
- copy .env.example
cp .env.example .env
define the variables
SQLALCHEMY_DATABASE_URI
docker build -t myflask .
run
docker run --env-file .env -p 5000:5000 myflask
docker-compose up --build
in order to install mysqlclient dependency, install the corresponding libpython-dev, e,g,
sudo apt install libmysqlclient-dev
sudo apt install libpython3.10-dev