[Flask] endpoint when running flask app as cgi?
keith macdonald
keith at the-sanctuary.biz
Tue Apr 10 16:12:10 EDT 2018
Just wondering, is the root folder for the Flask app-route the same as the
cgi-bin folder?
----------------------------------------------------------------------
Today's Topics:
1. endpoint when running flask app as cgi? (Stuart McGraw)
----------------------------------------------------------------------
Message: 1
Date: Sun, 8 Apr 2018 17:06:28 -0600
From: Stuart McGraw <smcg4191 at mtneva.com>
To: flask at python.org
Subject: [Flask] endpoint when running flask app as cgi?
Message-ID: <4e172472-f803-f4dc-3c33-e9364e037aed at mtneva.com>
Content-Type: text/plain; charset=utf-8; format=flowed
Hello,
The following, myapp.py, runs fine when I run it directly (ie using Flask's
built-in server):
App = Flask ('myapp')
@App.route('/')
def hello_world():
return 'Hello, world'
def main():
App.run (host='0.0.0.0', debug=True)
if __name__ == '__main__': main()
But I want to run it as a cgi script so per the Flask docs I created the
following, cgiapp.py in my webserver's cgi-bin/ directory:
#!/usr/bin/python3
import sys; sys.path.append ('/home/me/devel')
from wsgiref.handlers import CGIHandler
from myapp import App
CGIHandler().run (App)
But when I access the url for the cgi script I get a 404 error.
I am certain the web server, cgi, etc is configured correctly (if I replace
the CGIHandler call with print statements, the I get the expected web page;
the 404 is being generated by Flask in the app code.)
I guess I need something other than "/" in the App.route() decorator but I
am not sure what. I *have* read the Flask docs (multiple times) without
enlightenment and my stab-in-the-dark guesses not been productive.
Hints? (or better yet an answer? :-)
------------------------------
Subject: Digest Footer
_______________________________________________
Flask mailing list
Flask at python.org
https://mail.python.org/mailman/listinfo/flask
------------------------------
End of Flask Digest, Vol 34, Issue 1
************************************
More information about the Flask
mailing list