-
-
Notifications
You must be signed in to change notification settings - Fork 16.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Exception when trying to run Flask app via CGIHandler #857
Comments
I too am seeing this, I'm trying to track down what is causing the problem. Here is some information I've managed to get. My .htaccess appears below and is followed by server information and the traceback. The recommended routing in the flask documentation returned 500, this was what I found to work. I'm keeping open the possibility of a server configuration problem as well. I've removed what I feel to be personal information including my username, server name, server address, and admin email.
Error in application running REQUEST_METHOD: GET Exception occured: AttributeError: 'NoneType' object has no attribute 'lstrip' |
Well, I've played around some more and seem to have got a working configuration. My .htaccess file looks like:
This is the same as the flask recommendation http://flask.pocoo.org/docs/deploying/cgi/, except I've removed the comment on the second line. I'm not sure if that was the intention of the documentation to have an actual comment in the .htaccess file. It appears the sketchy workaround I found was causing the actual problem with flask. I cannot tell you if the initiator of this bug followed a similar path to cause the bug. Cheers, prad |
(You know that using CGI is a bad idea, right?) |
I'm aware that it is very limited, but it is the only option on the server we are provided. |
pradloff: I'll fiddle around with my Apache config and see what happens. But I definitely had no line in it with a trailing line comment. ThiefMaster: I disagree. It's often the only way to run Python on common PHP/MySQL-class hostings, and it's a good choice for self-hosting many tiny, seldomly accessed apps for which one doesn't want to have processes lurking around and supervisors to be configured. |
OK, just a bit more background: I wrote a bunch of CGI scripts and want to make them WSGI-compatible so they can be served "in a modern fashion". But not being able to actually run the new versions with CGI (via WSGI) would keep the existing users that want/need CGI from updating. In this state, i. e. ported to Flask, but unable to be run via GCI, I'm kept from releasing the new versions. |
Bug introduced in pallets/werkzeug@daad951#L0L1231 |
If you add a trailing slash to the url, it works for me. Thanks a lot for your help, |
No idea. I pinged @mitsuhiko about this in IRC. |
I tested it myself. It seems to be sufficient to use the first part of your pull request. |
Yes, the second part are just tests that fail unless the first part is applied. |
This is a bug in the CGI handler. PATH_INFO must not be None. |
To fix this use a middleware that fixes up the issue. See pallets/werkzeug#440 |
I have a very simple app. It runs fine when the module (itself calling
app.run()
) is run.However, when I try to run the app via CGI on Apache 2 using this
.cgi
script:it results in an exception:
The setup is Flask 0.10.1 with Werkzeug 0.9.4.
On first sight, the WSGI environment variables seem to be incomplete, or something like that.
The text was updated successfully, but these errors were encountered: