These instructions are for setting up Apache to retrieve pages from Gunicorn in order to workaround mod_wsgi not working. Note that Gunicorn does not work on Windows at the time of writing (October 3rd, 2016).
For nginx instructions refer to Gunicorn's example.
pip install gunicorn
On Linux, make a .sh with:
#!/bin/bash
gunicorn -w 1 app:app -b 0.0.0.0:8080
More information on configuring Gunicorn can be found in the documentation for Gunicorn.
We'll need to specify the directory for the static
resources so that images and such work correctly, and are served by Apache instead of Gunicorn.
<VirtualHost oursite.com>
LoadModule proxy_module modules/mod_proxy.so
LoadModule proxy_http_module modules/mod_proxy_http.so
# Tells apache where /static/ should go
Alias /static/ /full/path/to/flask/app/static/
# Proxy everything to gunicorn EXCEPT /static and favicon.ico
ProxyPass /favicon.ico !
ProxyPass /static !
ProxyPass /stats http://oursite.com:8080/
ProxyPassReverse /stats http://oursite.com:8080/
</VirtualHost>
Once this is set up, asssuming Gunicorn is running, browsing to http://oursite.com/stats
should serve this app via Gunicorn.
Since Gunicorn doesn't work for Windows, here's how to do the above with Gevent:
pip install gevent
Note: There is an example script in the repo titled example-gevent-deploy.py
which is identical to what I have below here. Use that if you'd like.
Make a new python script at the root of the project folder.
from gevent.wsgi import WSGIServer
from app import app
http_server = WSGIServer(('', 8080), app)
http_server.serve_forever()
For instructions on configuring the Apache reverse proxy, [see above](#Configuring Apache).