From smcg4191 at mtneva.com Sun Apr 8 19:06:28 2018 From: smcg4191 at mtneva.com (Stuart McGraw) Date: Sun, 8 Apr 2018 17:06:28 -0600 Subject: [Flask] endpoint when running flask app as cgi? Message-ID: <4e172472-f803-f4dc-3c33-e9364e037aed@mtneva.com> 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? :-) From keith at the-sanctuary.biz Tue Apr 10 16:12:10 2018 From: keith at the-sanctuary.biz (keith macdonald) Date: Tue, 10 Apr 2018 21:12:10 +0100 Subject: [Flask] endpoint when running flask app as cgi? In-Reply-To: References: Message-ID: <000001d3d108$356bff10$a043fd30$@biz> 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 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 ************************************ From spaceman at antispaceman.com Wed Apr 11 10:12:28 2018 From: spaceman at antispaceman.com (spaceman) Date: Wed, 11 Apr 2018 15:12:28 +0100 Subject: [Flask] Flask 2 language site with custom translations In-Reply-To: References: Message-ID: <20180411141228.927E580F@home.antispaceman.com> Hi Beqa, > so the problem is that how not to use session storage for changing language > and how to use url_prefix without babel and other additional items > how to have www.mysite.com/en and www.mysite.com/ka ? can anyone help me > get this done ? There are in-built mechanisms for determining the users language inside HTTP request headers: ACCEPT text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8 ACCEPT_ENCODING gzip, deflate ACCEPT_LANGUAGE en-GB <-- this header CONNECTION Keep-Alive HOST www.whatismybrowser.com Can you use that to determine which language to display instead of the session? You can also use Content-Language HTTP response header to indicate which language it is. Regards, spaceman From smcg4191 at mtneva.com Mon Apr 16 00:28:18 2018 From: smcg4191 at mtneva.com (Stuart McGraw) Date: Sun, 15 Apr 2018 22:28:18 -0600 Subject: [Flask] endpoint when running flask app as cgi? In-Reply-To: <000001d3d108$356bff10$a043fd30$@biz> References: <000001d3d108$356bff10$a043fd30$@biz> Message-ID: Thanks for that suggestion and sorry for the delay in responding... I put both files I showed in my original post (app file and the cgi shim) directly into the cgi-bin directory (and removed the now unneeded "import" statement in the cgi shim file) but got the same result (a 404 error). Things worked as advertised when I was a little more careful with the rewrite rules suggested in the docs. (http://flask.pocoo.org/docs/0.12/deploying/cgi/) My situation is that my Flask application will run on a system with minimal sys admin availability. I'd like to avoid any Apache configuration beyond basic cgi. What I'm hoping for is to be able to drop a myapp.py file in the system cgi-bin directory and have the app available at http://xx.com/cgi-bin/myapp.py/... Is there something I can do in either the flask app or the cgi shim that will have the same effect as the Apache rewrite rules suggested in the docs? I tried changing the values of the SCRIPT_NAME and REQUEST_URI environ values in the cgi shim, before it calls app.run() but without success, unsuprisingly because I don't understand what Werkzeug does with the environment values it gets and how those relate to the Flask routing decorator urls. Is there somewhere that describes how the cgi environment values get turned into values that get matched against the url rules? Or where I can look in the Flask/Werkzeug source? Thanks... On 04/10/2018 02:12 PM, keith macdonald wrote: > Just wondering, is the root folder for the Flask app-route the same as the > cgi-bin folder? > > From: Stuart McGraw > 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? From yoann.pageaud at gmail.com Mon Apr 16 09:23:49 2018 From: yoann.pageaud at gmail.com (Yoann Pageaud) Date: Mon, 16 Apr 2018 15:23:49 +0200 Subject: [Flask] How to prepopulate WTForm Textfields with MultiDict ? Message-ID: Hi all, I am trying to prepopulate WTForm Textfields with information parsed from a text file. I made a function able to create a MultiDict that is supposed to be used to prepopulate a WTForm I have. I already created an issue on StackOverflow with all details here: https://stackoverflow.com/questions/49753817/flask-prepopulating-wtform-with-multidict-does-not-work-for-textfields-only-r I haven't found yet the good solution to pre-populate the Textfields, but I think I am close. If someone has an idea of why it does not work for Textfields, I would be grateful of any kind of help you can provide me. Best regards, -- Yoann PAGEAUD -------------- next part -------------- An HTML attachment was scrubbed... URL: From kinsella.ben at gmail.com Fri Apr 27 08:21:11 2018 From: kinsella.ben at gmail.com (Ben Kinsella) Date: Fri, 27 Apr 2018 13:21:11 +0100 Subject: [Flask] Why is a small response broken into 3 TCP segments? Message-ID: I am working with a very limited client in an embedded device, and I would like the HTTP response from my Flask app to be contained in one IP packet. I know a response will be automatically segmented if the size exceeds my TCP MSS (1460 bytes). But I find that, even with a minimal ?Hello World? response (112 bytes), the response is sent in multiple IP packets (each containing one TCP segment). With Flask's builtin server, the response comes in 3 segments: start line, headers, body. With Gevent as the server, the same response comes in 2 segments: start line & headers, body. Is this behaviour configurable at any level? (Werkzeug, Flask, Gevent, any another server?). Thanks, Ben. -------------- next part -------------- An HTML attachment was scrubbed... URL: From fredrik.blomqvist.95 at gmail.com Mon Apr 30 22:26:17 2018 From: fredrik.blomqvist.95 at gmail.com (Fredrik Blomqvist) Date: Tue, 01 May 2018 02:26:17 +0000 Subject: [Flask] Multiple signals sent by got_request_exception Message-ID: Hello, I'm dealing with an odd bug where multiple signals are being sent by got_request_exception. I'm at a loss on how to debug this. It is the same amount every time an exception occurs: 3. I have checked the list of receivers and it is always just 1, which is correct. The receiver is connected using the "connect" method. If anyone can give me any advice on what could be wrong I'd be grateful! I'm running the latest Flask (1.0) on Python 3.6. I have verified that it's not a bug since it doesn't happen in a small example app. Best, Fredrik -------------- next part -------------- An HTML attachment was scrubbed... URL: