This code base will have getting started with structure for Python Flask application for API development, along with database connections
Make sure you have installed python :) To check python version,
python -V
Make sure you have installed
python-pip
-
Checkout code
git clone https://github.com/srikanthjeeva/python-flask-getting-started.git cd python-flask-getting-started -
Install dependencies, (use sudo if required)
pip install -r requirements.txt or -
Configure environment (the app defaults to
production, with debug off)export ENV=development # development | testing | production export SECRET_KEY='change-me' # required for stable sessions in production export DATABASE_URL='mysql+pymysql://user:password@host/dbname' -
start server
python server.pyThe dev server listens on 127.0.0.1 only. Set
FLASK_RUN_HOSTto change it, but never expose the server to a network while debug mode is on. -
In browser go to,
http://localhost:5000 or http://localhost:5000/hello or for UI http://localhost:5000/ui/hello
docker ps
docker images
docker build -t pygs:1.0.0 .
docker run -d -p 5000:5000 -e SECRET_KEY='change-me' -e DATABASE_URL='...' pygs:1.0.0