Setup front end with plotly dash, flask, gunicorn and nginx - OXPHOS/GeneMiner GitHub Wiki
flask
framework
1. Setup Refer to instructions at: https://github.com/InsightDataScience/data-engineering-ecosystem/wiki/Flask
dash
application on top of flask
2. Build dash
and components can be downloaded via pip
.
To connect dash
to flask
:
# Define for IIS module registration.
wsgi_app = app.wsgi_app
# Connect dash to flask
dashapp = dash.Dash(__name__, server=app, url_base_pathname='/')
3. Get a domain
Buy a domain at namecheap.com
4. Point domain name to EC2 instances
Follow the instructions here: http://techgenix.com/namecheap-aws-ec2-linux/ Create host zones and add the servers to domain's custom DNS
Nginx
and gunicorn
5. sudo apt-get install nginx
conda install gunicorn
sudo /etc/init.d/nginx
sudo rm /etc/nginx/sites-enabled/default
sudo touch /etc/nginx/sites-available/application
sudo ln -s /etc/nginx/sites-available/application /etc/nginx/sites-enabled/application
sudo nano /etc/nginx/sites-enabled/application
And paste (exactly):
server {
location / {
proxy_pass http://localhost:8000;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
}
}
Finally, run
gunicorn foldername:appvariablename
outside the folder. (Appvariablename: Flask(__name__)
)
In this case:
GeneMiner/flask-dash-app $ gunicorn app:app
To run in the background:
GeneMiner/flask-dash-app $ gunicorn app:app -D
Kill the process:
pkill gunicorn