cgi.rst
This file
Path
docs/deploying/cgi.rst
46 lines · 1.4 KiB
Last changed by
Touch up and integrate docs on deploying Flask.Ron DuPlainbefore adoption207006f
History of this fileTake it
The walk stopped after 200 commits: lines older than f5b8c08 point at it.
endpoint is optional for modules. This fixes #86Armin Ronacherbefore adoptionf5b8c08
lines 1–3why, one step back1CGI2===3Touch up and integrate docs on deploying Flask.Ron DuPlainbefore adoption207006f
lines 4–5why, one step back4If all other deployment methods do not work, CGI will work for sure.5CGI is supported by all major servers but usually has a sub-optimalendpoint is optional for modules. This fixes #86Armin Ronacherbefore adoptionf5b8c08
lines 6–7why, one step back6performance.7Touch up and integrate docs on deploying Flask.Ron DuPlainbefore adoption207006f
lines 8–9why, one step back8This is also the way you can use a Flask application on Google's `App9Engine`_, where execution happens in a CGI-like environment.endpoint is optional for modules. This fixes #86Armin Ronacherbefore adoptionf5b8c08
lines 10–12why, one step back1011.. admonition:: Watch Out12Touch up and integrate docs on deploying Flask.Ron DuPlainbefore adoption207006f
lines 13–17why, one step back13 Please make sure in advance that any ``app.run()`` calls you might14 have in your application file are inside an ``if __name__ ==15 '__main__':`` block or moved to a separate file. Just make sure it's16 not called because this will always start a local WSGI server which17 we do not want if we deploy that application to CGI / app engine.endpoint is optional for modules. This fixes #86Armin Ronacherbefore adoptionf5b8c08
lines 18–34why, one step back1819Creating a `.cgi` file20----------------------2122First you need to create the CGI application file. Let's call it23`yourapplication.cgi`::2425 #!/usr/bin/python26 from wsgiref.handlers import CGIHandler27 from yourapplication import app2829 CGIHandler().run(app)3031Server Setup32------------3334Usually there are two ways to configure the server. Either just copy theMerge branch 'master' of github.com:mitsuhiko/flaskArmin Ronacherbefore adoption5ecf01d
line 35why, one step back35`.cgi` into a `cgi-bin` (and use `mod_rewrite` or something similar toendpoint is optional for modules. This fixes #86Armin Ronacherbefore adoptionf5b8c08
lines 36–44why, one step back36rewrite the URL) or let the server point to the file directly.3738In Apache for example you can put a like like this into the config:3940.. sourcecode:: apache4142 ScriptAlias /app /path/to/the/application.cgi4344For more information consult the documentation of your webserver.Touch up and integrate docs on deploying Flask.Ron DuPlainbefore adoption207006f
lines 45–46why, one step back4546.. _App Engine: http://code.google.com/appengine/