FlaskResearch 

TB Wiki

Login

FlaskResearch

Here are some articles on flask:

How to install flash/gunicorn on Ubuntu 18.04 and use nginx as a reverse proxy:

Notes [edit section]

flask has a built-in web server, but it does not scale.

However a flask app IS a WSGI-compatible app.

See https://flask.palletsprojects.com/en/1.1.x/deploying/mod_wsgi/ for how to install a flash application with Apache and mod_wsgi (Apache is what I have on birdcloud.org)

See https://flask.palletsprojects.com/en/1.1.x/deploying/#deployment for other deployment options.

Using mod_wsgi with apache [edit section]

See https://www.howtoforge.com/tutorial/how-to-run-python-scripts-with-apache-and-mod_wsgi-on-ubuntu-18-04/

Here's what I did on birdcloud:

  • $ sudo apt-get install libapache2-mod-wsgi -y
  • $ vi /var/www/owncloud/wsgy.py (see script for contents)
  • $ chown www-data:www-data /var/www/owncloud/wsgy.py
  • $ chmod 755 /var/www/owncloud/wsgy.py
  • $ echo "WSGIScriptAlias /wsgi /var/www/owncloud/wsgy.py" >/etc/apache2/conf-available/wsgi.conf
  • $ a2enconf wsgi
    • (only need to run this once, to enable wsgi in apache configuration)
  • $ systemctl restart apache2
    • (need to run this every time you change the wsgi.conf file)
  • $ browser https://birdcloud.org/wsgi

I made another script /var/www/owncloud/test_wsgi.py that mirrors the actions of /var/lib/cgi-bin/test_cgi.py

I did this in order to test responsiveness of cgi vs wsgi.

  • test.cgi loads in about 40 milliseconds
  • test_wsgi loads in about 9 milliseconds and that's with wsgi.mod_wsgi.script_reloading=1

putting mod_wsgi into daemon mode to avoid app reload [edit section]

See this information:

https://stackoverflow.com/questions/766601/mod-wsgi-force-reload-modules

https://modwsgi.readthedocs.io/en/develop/user-guides/reloading-source-code.html

TBWiki engine 1.9.1 by Tim Bird