Flask boilerplate based on cookiecutter-flask running on Docker with uWSGI& Nginx
Using the following repo:
If you create a flask template with cookiecutter-flask, you basically need to copy five files and edit as you need.
conda create -n py35env python=3.5
source activate py35env
git clone https://github.com/otwn/flask-on-docker
cd flask-on-docker
pip install -r requirements.txt
bower install
Then run the following commands
export FLASK_APP=/path/to/autoapp.py
export FLASK_DEBUG=1
flask run
The same flask application will run on docker in port 8000.
./init_docker.sh
Pymongo is installed and added pymongo settings on main/public/views.py. Change MONGODB_HOST. It should be your host machine’s ip address.
# MongoDB Connection
from pymongo import MongoClient
import json
from bson import json_util
from bson.json_util import dumps
MONGODB_HOST = 'Your Host IP address'
MONGODB_PORT = 27017
def get_db():
c = MongoClient(MONGODB_HOST, MONGODB_PORT)
return c.yourdatabase
ProxyPass /flask/ http://localhost:8000/
ProxyPassReverse /flask/ http://localhost/flask/
```
We can show the Flask app on Docker via proxy.
To change the subdirectory name, replace ‘flask’ by ‘your_subdirectory’ from the following files