CGI

If all other deployment methods do not work, CGI will work for sure. CGIis supported by all major servers but usually has a less-than-optimalperformance.

This is also the way you can use a Werkzeug application on Google’sAppEngine, there however the execution does happen in a CGI-likeenvironment. The application’s performance is unaffected because of that.

Creating a .cgi file

First you need to create the CGI application file. Let’s call ityourapplication.cgi:

  1. #!/usr/bin/python
  2. from wsgiref.handlers import CGIHandler
  3. from yourapplication import make_app
  4. application = make_app()
  5. CGIHandler().run(application)

If you’re running Python 2.4 you will need the wsgiref package. Python2.5 and higher ship this as part of the standard library.

Server Setup

Usually there are two ways to configure the server. Either just copy the.cgi into a cgi-bin (and use mod_rerwite or something similar torewrite the URL) or let the server point to the file directly.

In Apache for example you can put a like like this into the config:

  1. ScriptAlias /app /path/to/the/application.cgi

For more information consult the documentation of your webserver.