librelist archives

« back to archive

Can not deploy as CGI

Can not deploy as CGI

From:
Jakob Eriksson
Date:
2012-12-07 @ 16:36

Followed the docs here http://flask.pocoo.org/docs/deploying/cgi/

Already made it work on WSGI.

Dummy, plain, CGI program which is not Flask but imports the same things,
works. (Hello world style.)

Not a virtualenv problem, since I don't have any virtualenv.

Using Flask 0.9, (ran pip install --upgrade flask)

Can someone confirm they got Flask working as CGI on Apache (or any
webserver)?


best regards,
Jakob

Re: [flask] Can not deploy as CGI

From:
Jakob Eriksson
Date:
2012-12-07 @ 16:42
The error: HTTP 500.  No logs written from Apache directive "ScriptLog
/tmp/cgi.log".


On December 7, 2012 at 5:36 PM Jakob Eriksson <jakob@aurorasystems.eu> wrote:
>
>
> Followed the docs here http://flask.pocoo.org/docs/deploying/cgi/
>
> Already made it work on WSGI.
>
> Dummy, plain, CGI program which is not Flask but imports the same things,
> works. (Hello world style.)
>
> Not a virtualenv problem, since I don't have any virtualenv.
>
> Using Flask 0.9, (ran pip install --upgrade flask)
>
> Can someone confirm they got Flask working as CGI on Apache (or any
> webserver)?
>
>
> best regards,
> Jakob

Re: [flask] Can not deploy as CGI

From:
Steven Kryskalla
Date:
2012-12-07 @ 16:45
On Fri, Dec 7, 2012 at 8:42 AM, Jakob Eriksson <jakob@aurorasystems.eu> wrote:
>
> The error: HTTP 500.  No logs written from Apache directive "ScriptLog
> /tmp/cgi.log".

Do you have shell access to the machine? Try running the script from
the shell (e.g. "./nameofscript.cgi") and see if you get a traceback.
Also use cgitb.enable():

http://docs.python.org/2/library/cgitb.html

-steve

Re: [flask] Can not deploy as CGI

From:
Jakob Eriksson
Date:
2012-12-10 @ 09:22

On December 7, 2012 at 5:45 PM Steven Kryskalla <skryskalla@gmail.com> wrote:
>
> Do you have shell access to the machine? Try running the script from
> the shell (e.g. "./nameofscript.cgi") and see if you get a traceback.
> Also use cgitb.enable():

Thank you. Tried cgitb.enable(), could see no difference in behavior. Anyway,
tried to run from command line, that was more revealing. It looks an awful
lot like the Flask function

  request.args.get('somename')

 does not work, it returns "None" for the query parameter: somename.


Unless I miss something, shouldn't you set the parameters in the QUERY_INFO
environment variable when running from the command line?
Like QUERY_INFO='somename=aname&somethingelse=9'

best regards,
Jakob

Re: [flask] Can not deploy as CGI

From:
Jakob Eriksson
Date:
2012-12-10 @ 10:35

On December 10, 2012 at 10:22 AM Jakob Eriksson <jakob@aurorasystems.eu>
wrote:
>
>   request.args.get('somename')
>
>  does not work, it returns "None" for the query parameter: somename.


Seems it does work. The problem is, you can't use print() when running
as a CGI, it will mess up output.

http://stackoverflow.com/a/13799083/193892


best regards,
Jakob

Re: [flask] Can not deploy as CGI

From:
Steven Kryskalla
Date:
2012-12-10 @ 10:26
On Mon, Dec 10, 2012 at 1:22 AM, Jakob Eriksson <jakob@aurorasystems.eu> wrote:
> Unless I miss something, shouldn't you set the parameters in the QUERY_INFO
> environment variable when running from the command line?
> Like QUERY_INFO='somename=aname&somethingelse=9'

Yes, that is a potential next step. Mostly I just wanted to see if
there were any import problems or anything before the app code runs
that was causing it to fail.

You said that a simple "hello world" CGI program runs, but is your
flask app also a simple "hello world" type of app? Can you share the
code? I just tried running a simple flask app using CGI with python's
CGIHTTPServer and apache 2.2 and both worked fine.

-steve