Skip to content
Myr

cgi.rst

This file

Path

docs/deploying/cgi.rst

47 lines · 1.5 KiB

Last changed by

We do not support 2.4, not even with CGI :)Armin Ronacherbefore adoption402f12b

History of this file

Take it

The walk stopped after 200 commits: lines older than e84ca8e point at it.

Clearified thatArmin Ronacherbefore adoptione84ca8e

lines 1–37why, one step back
1CGI
2===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`App Engine`_, there however the execution does happen in a CGI-like10environment. The application's performance is unaffected because of that.1112.. 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 do18 not want if we deploy that application to CGI / app engine.1920.. _App Engine: http://code.google.com/appengine/2122Creating 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)3334Server Setup35------------3637Usually there are two ways to configure the server. Either just copy the

Merge branch 'master' of github.com:mitsuhiko/flaskArmin Ronacherbefore adoption5ecf01d

line 38why, one step back
38`.cgi` into a `cgi-bin` (and use `mod_rewrite` or something similar to

Clearified thatArmin Ronacherbefore adoptione84ca8e

lines 39–47why, one step back
39rewrite the URL) or let the server point to the file directly.
4041In Apache for example you can put a like like this into the config:4243.. sourcecode:: apache4445 ScriptAlias /app /path/to/the/application.cgi4647For more information consult the documentation of your webserver.