After tinkering, you might want to make your app a bit more production ready and/or make it start when the system boots.

Although it is very handy to have it run on a local port, using WSCGI and apache makes it straightforward to do just that. There are a few gotchas though:

(this is on ubuntu 16.04, but it should apply to most OSes)

apt-get install libapache2-mod-wsgi

in /etc/apache2/sites-available:

<VirtualHost *:80>
        WSGIScriptAlias / /var/www/yourapp/
        AddType text/html .py

        ErrorLog ${APACHE_LOG_DIR}/error_myapp.log
        CustomLog ${APACHE_LOG_DIR}/access_myapp.log combined

then a2ensite
and reload apache.

in python:

application = web.application(urls, globals()).wsgifunc()

please note that application must appear exactly as above, you can't name it anything else.

since apache does not allow you to import MyModule directly, you need to add it like this (assuming it's in the same folder as your app)

import os
import sys
CURDIR = os.path.dirname(__file__)
import MyModule

--- also please see