WSGI for web apps
Silk platform version 1
Silk will execute scripts ending in .py within a Python FCGI handler that runs within the WSGI model. Scripts will be dynamically loaded as modules on the first request, and their 'request_handler' attribute should be set to the instance of a function implementing the start_response() callable.
Example WSGI script
1 2 3 4 5 6 7
def my_handler(environ, start_response): start_response('200 OK', [('Content-Type', 'text/plain')]) yield "Hello World\n" for k, v in sorted(environ.items()): yield "%s: %s\n" % (k, v) request_handler = my_handler
Reloading your app
The environment variable
wsgi_max_requests can be set to cause the FCGI wrapper to reload your Python script (module) every N requests. During development, you can set this to something very low to see incremental changes as you work. Otherwise, the FCGI wrapper will cache your code for
For example, in your .htaccess file:
SetEnv wsgi_max_requests 10
Silk platform version 2
Python applications use Phusion Passenger
as an app server. You can run an application by placing the following in an
.htaccess file in your
1 2 3 4
PassengerAppType wsgi PassengerStartupFile passenger_wsgi.py PassengerAppRoot /users/m/y/mynetid/www-root PassengerPython /usr/bin/python
PassengerAppRoot should be the full path to the directory where your
application's startup file is located.
PassengerPython should be the full path to your preferred version of Python.
|Python version||PassengerPython value|
Python modules are managed using the
You can see which modules are currently installed by typing
pip list, or see
which you have installed yourself with
pip list --user.
Additional modules can be installed by typing
pip install --user <modulename>,
which will place them in your home directory, under
Scripts or commands included with a module are placed in
can either be run directly from there or added to your PATH by adding a line
such as the following to