Python Web Applications on Tux

Tagged with: python3 tux

Python apps/frameworks on Tux (using uWSGI )

Python apps and frameworks with a WSGI - Web Server Gateway Interface - can be run on the uWSGI server, hosted at bvm48.cci.drexel.edu.

To create a uWSGI site, create a directory inside your public_html directory on Tux called "uwsgi". Inside of this directory, make an INI file like the following. Replace <<PORT>> with the port number you've been assigned by your professor, or gotten by visiting https://www.cs.drexel.edu/~bjb344/portman.php.  Replace abc123 with your username, and project.py with the name of your main Python file.

Note that in the INI file, comments must be on their own line. You can never have a comment (identified with a # symbol) at the end of a directive line, as that will break your server.

Also note that the structure of the Python file should begin with a function similar to / the same as the one below after the uwsgi block.

[uwsgi]
http-socket = 10.246.250.148:<<PORT>>
chdir = /home/abc123/public_html/uwsgi/
wsgi-file = project.py
processes = 4
threads = 2
def application(env, start_response):
    start_response('200 OK', [('Content-Type','text/html')])
    return [b"Hello World"]

In order for the uWSGI server to start serving your website, please use the command below to create a symlink in the uWSGI server directory, replacing {{INI_FILE_NAME}} with the name of the ini file for your Python application, {{username}} with your abc123 username, and {{term}} with the current term (eg Winter 2024-2025 would be WI24).

ln -s ~/public_html/uwsgi/{{INI_FILE_NAME}} /site/uwsgi/{{username}}-{{term}}.ini

To access your site, you'll need to be connected to VPN or on the campus network (Dragonfly3).

Then, visit http://bvm48.cci.drexel.edu:<<PORT>>, where <<PORT>> is the port you specified in the ini file you created above.


For more information, visit https://uwsgi-docs.readthedocs.io/en/latest/WSGIquickstart.html . This includes instructions on making ini files for specific frameworks.