1

Is it in fact possible to use Flask from a CGI?

If so, how? I am aware of the concise and nice looking documentation for CGI+Flask but it looks to me, like the request.args.get('varname') function is not working, when run as CGI. It certainly works for me on the same (Apache, Ubuntu 12.10) server when run as WSGI.

I came to the conclusion (or strong suspicion, rather) that args.get() is not working, after I ran the CGI script on the command line. It would just not pick up anything in QUERY_INFO.

Am I missing something vital about CGI in general, is it a bug in Flask, or what is going on here?

EDIT

The documentation for Flask is updated in git, but at the time of this writing not yet on the homepage. Just don't use any print in your Flask application and CGI should work fine.

Prof. Falken
  • 24,226
  • 19
  • 100
  • 173

1 Answers1

2

The args thing is a red herring.

The problem was in CGI, any print can mess up the output, and in this case it messed up the headers. Solution: don't print any debug info or anything, when run as a CGI.

Also;

"... Google’s App Engine, where execution happens in a CGI-like environment"

Apparently Google App Engine is similar to a CGI environment and the same print thing can be an issue there.

Community
  • 1
  • 1
Prof. Falken
  • 24,226
  • 19
  • 100
  • 173