Skip to content
Myr

cgi.rst

This file

Path

docs/deploying/cgi.rst

42 lines · 1.2 KiB

Last changed by

Break up deployment docs into separate documents.Armin Ronacherbefore adoptionc64a4e0

History of this file

Take it

1CGI2===34If all other deployment methods do not work, CGI will work for sure.  CGI5is supported by all major servers but usually has a less-than-optimal6performance.78This is also the way you can use a Flask application on Google's9`AppEngine`_, there however the execution does happen in a CGI-like10environment.  The application's performance is unaffected because of that.1112.. _AppEngine: http://code.google.com/appengine/1314Creating a `.cgi` file15----------------------1617First you need to create the CGI application file.  Let's call it18`yourapplication.cgi`::1920    #!/usr/bin/python21    from wsgiref.handlers import CGIHandler22    from yourapplication import app2324    CGIHandler().run(app)2526If you're running Python 2.4 you will need the :mod:`wsgiref` package.  Python272.5 and higher ship this as part of the standard library.2829Server Setup30------------3132Usually there are two ways to configure the server.  Either just copy the33`.cgi` into a `cgi-bin` (and use `mod_rerwite` or something similar to34rewrite the URL) or let the server point to the file directly.3536In Apache for example you can put a like like this into the config:3738.. sourcecode:: apache3940    ScriptAlias /app /path/to/the/application.cgi4142For more information consult the documentation of your webserver.