cgi.rst
This file
Path
docs/deploying/cgi.rst
50 lines · 1.6 KiB
Last changed by
Merge branch 'master' into config-supportArmin Ronacherbefore adoption78fc994
History of this fileTake it
The walk stopped after 200 commits: lines older than 9f0b242 point at it.
The testsuite skips JSON tests now is not available and runs the exampleArmin Ronacherbefore adoption9f0b242
lines 1–8why, one step back1CGI2===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'sMerge branch 'master' into config-supportArmin Ronacherbefore adoption78fc994
line 9why, one step back9`App Engine`_, there however the execution does happen in a CGI-likeThe testsuite skips JSON tests now is not available and runs the exampleArmin Ronacherbefore adoption9f0b242
lines 10–11why, one step back10environment. The application's performance is unaffected because of that.11Added troubleshooting infos. This fixes #44Armin Ronacherbefore adoptioncc8332e
lines 12–17why, one step back12.. admonition:: Watch Out1314 Please make sure in advance that your ``app.run()`` call you might15 have in your application file, is inside an ``if __name__ ==16 '__main__':`` or moved to a separate file. Just make sure it's not17 called because this will always start a local WSGI server which we doMerge branch 'master' into config-supportArmin Ronacherbefore adoption78fc994
line 18why, one step back18 not want if we deploy that application to CGI / app engine.Added troubleshooting infos. This fixes #44Armin Ronacherbefore adoptioncc8332e
line 19why, one step back19Merge branch 'master' into config-supportArmin Ronacherbefore adoption78fc994
line 20why, one step back20.. _App Engine: http://code.google.com/appengine/The testsuite skips JSON tests now is not available and runs the exampleArmin Ronacherbefore adoption9f0b242
lines 21–50why, one step back2122Creating a `.cgi` file23----------------------2425First you need to create the CGI application file. Let's call it26`yourapplication.cgi`::2728 #!/usr/bin/python29 from wsgiref.handlers import CGIHandler30 from yourapplication import app3132 CGIHandler().run(app)3334If you're running Python 2.4 you will need the :mod:`wsgiref` package. Python352.5 and higher ship this as part of the standard library.3637Server Setup38------------3940Usually there are two ways to configure the server. Either just copy the41`.cgi` into a `cgi-bin` (and use `mod_rerwite` or something similar to42rewrite the URL) or let the server point to the file directly.4344In Apache for example you can put a like like this into the config:4546.. sourcecode:: apache4748 ScriptAlias /app /path/to/the/application.cgi4950For more information consult the documentation of your webserver.