From alenaslifar at gmail.com Tue Jul 4 16:45:13 2017 From: alenaslifar at gmail.com (Alena Lifar) Date: Tue, 4 Jul 2017 23:45:13 +0300 Subject: [Flask] Flask Extension Development Message-ID: Hello everyone, My name is Alena and I have been working on a Flask Extension that collects and exposes routes declared in your Flask application/Blueprint via REST. Here is Github project: https://github.com/UseTheApi/flask_url_discovery Could anyone please take a look and let me know if this could be useful? Do you think it has a chance to be added into Flask Extension Registry? Is there anything I have to improve? I have found this link: http://librelist.com/browser/flask/2010/7/25/flask- extension-review-status/ which points to http://github.com/ mitsuhiko/flask/tree/master/extreview/ for Flask Extensions review and approval but this link is dead. Thank you for your time. Kind regards, Alena -------------- next part -------------- An HTML attachment was scrubbed... URL: From joanbr at gmail.com Tue Jul 4 17:17:14 2017 From: joanbr at gmail.com (Joan Bales) Date: Tue, 4 Jul 2017 23:17:14 +0200 Subject: [Flask] Flask Mega-Tutorial Message-ID: Hi there! Flask fans, this one will be interesting for someone, from our best read Flask tutorial guy, Miguel Grinberg. https://www.kickstarter.com/projects/1124925856/the-new-and-improved-flask-mega-tutorial Bests, Joan -------------- next part -------------- An HTML attachment was scrubbed... URL: From gergely at polonkai.eu Wed Jul 5 04:33:04 2017 From: gergely at polonkai.eu (Gergely Polonkai) Date: Wed, 05 Jul 2017 08:33:04 +0000 Subject: [Flask] Flask Extension Development In-Reply-To: References: Message-ID: Hello, I like the idea, although unless I can deliberately hide some views, or much better, if I can select which routes I want to expose, this is a no-go. There are routes in some of my apps I definitely don't want to expose, like administrative ones. Also, with routes that require parameters, you will have to expose metadata on what type of data goes there, what the format might be, etc. And even though I tell my users to put an integer in a specific parameter, attackers will still try to inject something else to exploit my app (although that might happen even if I don't expose my routes.) Be ready for security concerns on the long run! About the Flask registry, I wouldn't bother uploading it there until some level of maturity. Post the library here and there, and if others like it and start using it, you may think about it again. Best, Gergely On Tue, Jul 4, 2017, 22:45 Alena Lifar wrote: > Hello everyone, > > My name is Alena and I have been working on a Flask Extension that > collects and exposes routes declared in your Flask application/Blueprint > via REST. > > Here is Github project: https://github.com/UseTheApi/flask_url_discovery > > Could anyone please take a look and let me know if this could be useful? > Do you think it has a chance to be added into Flask Extension Registry? Is > there anything I have to improve? > > I have found this link: > http://librelist.com/browser/flask/2010/7/25/flask-extension-review-status/ which > points to http://github.com/mitsuhiko/flask/tree/master/extreview/ for > Flask Extensions review and approval but this link is dead. > > Thank you for your time. > > Kind regards, > Alena > _______________________________________________ > Flask mailing list > Flask at python.org > https://mail.python.org/mailman/listinfo/flask > -------------- next part -------------- An HTML attachment was scrubbed... URL: From alenaslifar at gmail.com Wed Jul 5 05:36:13 2017 From: alenaslifar at gmail.com (Alena Lifar) Date: Wed, 5 Jul 2017 12:36:13 +0300 Subject: [Flask] Flask Extension Development In-Reply-To: References: Message-ID: Hi Gergely, I completely agree that exposing all routes without an option of hiding some of them is a no-go. In my package you can use private() decorator func in order to hide either a route or a Blueprint. I have put some examples in the Readme: @private()@app.route('/restricted_route/')def private_endpoint(): return 'Hello Private Endpoint' As well as Blueprints: # or: app_bp = private(Blueprint('my_bp', __name__)) app_bp = Blueprint('my_bp', __name__) private(app_bp) Does it correlate to your suggestion? My vision of requests with parameters was to just put those in the available url string as is (just like they were put in route()): "hello_world": { // name of a public endpoint "active_urls": [ "/", "/health_check//" ], "methods": [ "GET", "HEAD", "OPTIONS" ] }, By providing more information like required param format or an example of response format for a given route I think I'd create a vulnerability. I think that everything about data formats has to be in the API docs. This extension aimed to get rid of hardcoded api urls in the components/client code mostly... Please, let me know what you think. P.S. I'm quite new to contributing something valuable to the open-source. Could you please suggest me any resources that I might share my work with? Thank you for your help and for the feedback. Kind regards, Alena On Wed, Jul 5, 2017 at 11:34 AM, Alena Lifar wrote: > Hi Abdesslem, > > Awesome, thanks! > > Kind regards, > Alena > > On Wed, Jul 5, 2017 at 9:31 AM, Abdesslem Amri > wrote: > >> Hi, >> >> To add a new extension. you have to make a pull request to >> https://github.com/pallets/flask-website. >> >> Best regards, >> Abdesslem Amri >> >> 2017-07-04 22:45 GMT+02:00 Alena Lifar : >> >>> Hello everyone, >>> >>> My name is Alena and I have been working on a Flask Extension that >>> collects and exposes routes declared in your Flask application/Blueprint >>> via REST. >>> >>> Here is Github project: https://github.com/UseTheApi/flask_url_discovery >>> >>> Could anyone please take a look and let me know if this could be useful? >>> Do you think it has a chance to be added into Flask Extension Registry? Is >>> there anything I have to improve? >>> >>> I have found this link: http://librelist.com/bro >>> wser/flask/2010/7/25/flask-extension-review-status/ which points to >>> http://github.com/mitsuhiko/flask/tree/master/extreview/ for Flask >>> Extensions review and approval but this link is dead. >>> >>> Thank you for your time. >>> >>> Kind regards, >>> Alena >>> >>> _______________________________________________ >>> Flask mailing list >>> Flask at python.org >>> https://mail.python.org/mailman/listinfo/flask >>> >>> >> >> >> -- >> ------------------------------ >> >> The preceding message (including attachments) is covered by the >> Electronic Communication Privacy Act, 18 U.S.C. sections 2510-2512, is >> intended only for the person or entity to which it is addressed, and may >> contain information that is confidential, protected by attorney-client or >> other privilege, or otherwise protected from disclosure by law. If you are >> not the intended recipient, you are hereby notified that any retention, >> dissemination, distribution, or copying of this communication is strictly >> prohibited. Please reply to the sender that you have received the message >> in error and destroy the original message and all copies. >> >> _______________________________________________ >> > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From rmorgan466 at gmail.com Thu Jul 6 21:02:00 2017 From: rmorgan466 at gmail.com (Rita) Date: Thu, 6 Jul 2017 21:02:00 -0400 Subject: [Flask] flask queue question Message-ID: Been using flask in my lab for the past few years. It just works. We recently got some grad students and it seems we are seeing some slowness in our flask applications running on Windows 2012 with enthought python. currently I am running it in a single threaded mode with nginx ( http://flask.pocoo.org/docs/0.12/deploying/wsgi-standalone/#proxy-setups). My question is: When 2 users hit my flask page, does it get blocked until the first user finishes his request - it seems that the case. Is there a way to view the "queue" length? How is this queue maintained, or is it done by operating system networking stack? -- --- Get your facts first, then you can distort them as you please.-- -------------- next part -------------- An HTML attachment was scrubbed... URL: From amriabdesslem at gmail.com Fri Jul 7 03:19:04 2017 From: amriabdesslem at gmail.com (Abdesslem Amri) Date: Fri, 7 Jul 2017 09:19:04 +0200 Subject: [Flask] flask queue question In-Reply-To: References: Message-ID: Using the simple app.run() from within Flask creates a single synchronous server on a single thread capable of serving only one client at a time. 2017-07-07 3:02 GMT+02:00 Rita : > Been using flask in my lab for the past few years. It just works. We > recently got some grad students and it seems we are seeing some slowness in > our flask applications running on Windows 2012 with enthought python. > > currently I am running it in a single threaded mode with nginx ( > http://flask.pocoo.org/docs/0.12/deploying/wsgi-standalone/#proxy-setups). > My question is: When 2 users hit my flask page, does it get blocked until > the first user finishes his request - it seems that the case. Is there a > way to view the "queue" length? How is this queue maintained, or is it done > by operating system networking stack? > > > > -- > --- Get your facts first, then you can distort them as you please.-- > > _______________________________________________ > Flask mailing list > Flask at python.org > https://mail.python.org/mailman/listinfo/flask > > -- ------------------------------ The preceding message (including attachments) is covered by the Electronic Communication Privacy Act, 18 U.S.C. sections 2510-2512, is intended only for the person or entity to which it is addressed, and may contain information that is confidential, protected by attorney-client or other privilege, or otherwise protected from disclosure by law. If you are not the intended recipient, you are hereby notified that any retention, dissemination, distribution, or copying of this communication is strictly prohibited. Please reply to the sender that you have received the message in error and destroy the original message and all copies. _______________________________________________ -------------- next part -------------- An HTML attachment was scrubbed... URL: From rmorgan466 at gmail.com Fri Jul 7 06:33:23 2017 From: rmorgan466 at gmail.com (Rita) Date: Fri, 7 Jul 2017 06:33:23 -0400 Subject: [Flask] flask queue question In-Reply-To: References: Message-ID: yes, i understand that. how come when i submit ten concurrent requests none of them get lost and eventually finish? how is that maintained? On Fri, Jul 7, 2017 at 3:19 AM, Abdesslem Amri wrote: > Using the simple app.run() from within Flask creates a single synchronous > server on a single thread capable of serving only one client at a time. > > 2017-07-07 3:02 GMT+02:00 Rita : > >> Been using flask in my lab for the past few years. It just works. We >> recently got some grad students and it seems we are seeing some slowness in >> our flask applications running on Windows 2012 with enthought python. >> >> currently I am running it in a single threaded mode with nginx ( >> http://flask.pocoo.org/docs/0.12/deploying/wsgi-standalone/#proxy-setups). >> My question is: When 2 users hit my flask page, does it get blocked until >> the first user finishes his request - it seems that the case. Is there a >> way to view the "queue" length? How is this queue maintained, or is it done >> by operating system networking stack? >> >> >> >> -- >> --- Get your facts first, then you can distort them as you please.-- >> >> _______________________________________________ >> Flask mailing list >> Flask at python.org >> https://mail.python.org/mailman/listinfo/flask >> >> > > > -- > ------------------------------ > > The preceding message (including attachments) is covered by the Electronic > Communication Privacy Act, 18 U.S.C. sections 2510-2512, is intended only > for the person or entity to which it is addressed, and may contain > information that is confidential, protected by attorney-client or other > privilege, or otherwise protected from disclosure by law. If you are not > the intended recipient, you are hereby notified that any retention, > dissemination, distribution, or copying of this communication is strictly > prohibited. Please reply to the sender that you have received the message > in error and destroy the original message and all copies. > > _______________________________________________ > -- --- Get your facts first, then you can distort them as you please.-- -------------- next part -------------- An HTML attachment was scrubbed... URL: From ziirish at ziirish.info Fri Jul 7 08:10:48 2017 From: ziirish at ziirish.info (Ziirish) Date: Fri, 7 Jul 2017 14:10:48 +0200 Subject: [Flask] flask queue question In-Reply-To: References: Message-ID: <20170707121048.GW5364@mail.ziirish.info> Hello, Here is a simplified view of the underlying parts on which the Flask's "built-in server" is built (with the default settings): Flask.run() -> werkzeug.serving.run_simple() -> BaseHTTPServer.HTTPServer() -> SocketServer.TCPServer() Sources: https://github.com/pallets/flask/blob/master/flask/app.py#L823 https://github.com/pallets/werkzeug/blob/master/werkzeug/serving.py#L605 https://github.com/pallets/werkzeug/blob/master/werkzeug/serving.py#L576 https://docs.python.org/2/library/basehttpserver.html https://docs.python.org/2/library/socketserver.html#SocketServer.TCPServer On this last page you can read: > These four classes process requests synchronously; each request must be > completed before the next request can be started. This isn?t suitable if > each request takes a long time to complete, because it requires a lot of > computation, or because it returns a lot of data which the client is slow > to process. The solution is to create a separate process or thread to handle > each request; the ForkingMixIn and ThreadingMixIn mix-in classes can be used > to support asynchronous behaviour. So yes, the requests are processed synchronously by default, and the request queue size is 5 (https://docs.python.org/2/library/socketserver.html#SocketServer.BaseServer.request_queue_size). This means you can only have 5 queued requests, the other will just get rejected. Unfortunately, werkzeug does not provide any mean to override the default request_queue_size, but according to the socket.listen doc (where this setting is used), this value seem reasonably chosen: https://docs.python.org/2/library/socket.html#socket.socket.listen Now, here are your options. As stated in the doc (http://flask.pocoo.org/docs/0.12/deploying/), the built-in server is *not* suitable for *production*. You can however choose whatever solution you feel the more comfortable with here: http://flask.pocoo.org/docs/0.12/deploying/#self-hosted-options These will probably allow you to tweak the queue size, serve multiple requests concurrently, etc. * On Friday, July 07, 2017 at 06:33 AM -0400, Rita wrote: > yes, i understand that. how come when i submit ten concurrent requests none > of them get lost and eventually finish? how is that maintained? > > On Fri, Jul 7, 2017 at 3:19 AM, Abdesslem Amri > wrote: > > > Using the simple app.run() from within Flask creates a single synchronous > > server on a single thread capable of serving only one client at a time. > > > > 2017-07-07 3:02 GMT+02:00 Rita : > > > >> Been using flask in my lab for the past few years. It just works. We > >> recently got some grad students and it seems we are seeing some slowness in > >> our flask applications running on Windows 2012 with enthought python. > >> > >> currently I am running it in a single threaded mode with nginx ( > >> http://flask.pocoo.org/docs/0.12/deploying/wsgi-standalone/#proxy-setups). > >> My question is: When 2 users hit my flask page, does it get blocked until > >> the first user finishes his request - it seems that the case. Is there a > >> way to view the "queue" length? How is this queue maintained, or is it done > >> by operating system networking stack? From paradox2005 at gmail.com Fri Jul 7 08:54:26 2017 From: paradox2005 at gmail.com (Adil Hasan) Date: Fri, 7 Jul 2017 13:54:26 +0100 Subject: [Flask] flask queue question In-Reply-To: References: Message-ID: <20170707125423.GG4010@raddish> Hello Rita, I wonder. Do you think that the nginx server is handling the requests? I think the webserver is the service that will manage requests. At least I think that it is. hth adil On Fri, Jul 07, 2017 at 06:33:23AM -0400, Rita wrote: > yes, i understand that. how come when i submit ten concurrent requests none > of them get lost and eventually finish? how is that maintained? > > On Fri, Jul 7, 2017 at 3:19 AM, Abdesslem Amri > wrote: > > > Using the simple app.run() from within Flask creates a single synchronous > > server on a single thread capable of serving only one client at a time. > > > > 2017-07-07 3:02 GMT+02:00 Rita : > > > >> Been using flask in my lab for the past few years. It just works. We > >> recently got some grad students and it seems we are seeing some slowness in > >> our flask applications running on Windows 2012 with enthought python. > >> > >> currently I am running it in a single threaded mode with nginx ( > >> http://flask.pocoo.org/docs/0.12/deploying/wsgi-standalone/#proxy-setups). > >> My question is: When 2 users hit my flask page, does it get blocked until > >> the first user finishes his request - it seems that the case. Is there a > >> way to view the "queue" length? How is this queue maintained, or is it done > >> by operating system networking stack? > >> > >> > >> > >> -- > >> --- Get your facts first, then you can distort them as you please.-- > >> > >> _______________________________________________ > >> Flask mailing list > >> Flask at python.org > >> https://mail.python.org/mailman/listinfo/flask > >> > >> > > > > > > -- > > ------------------------------ > > > > The preceding message (including attachments) is covered by the Electronic > > Communication Privacy Act, 18 U.S.C. sections 2510-2512, is intended only > > for the person or entity to which it is addressed, and may contain > > information that is confidential, protected by attorney-client or other > > privilege, or otherwise protected from disclosure by law. If you are not > > the intended recipient, you are hereby notified that any retention, > > dissemination, distribution, or copying of this communication is strictly > > prohibited. Please reply to the sender that you have received the message > > in error and destroy the original message and all copies. > > > > _______________________________________________ > > > > > > -- > --- Get your facts first, then you can distort them as you please.-- > _______________________________________________ > Flask mailing list > Flask at python.org > https://mail.python.org/mailman/listinfo/flask From rmorgan466 at gmail.com Fri Jul 7 08:56:59 2017 From: rmorgan466 at gmail.com (Rita) Date: Fri, 7 Jul 2017 08:56:59 -0400 Subject: [Flask] flask queue question In-Reply-To: <20170707125423.GG4010@raddish> References: <20170707125423.GG4010@raddish> Message-ID: yeah, my traffic is going thru nginx. Its acting as a proxy. Can you recommend a good wsgi server for windows? On Fri, Jul 7, 2017 at 8:54 AM, Adil Hasan wrote: > Hello Rita, > I wonder. Do you think that the nginx server is handling the requests? > I think the webserver is the service that will manage requests. At least > I think that it is. > hth > adil > > On Fri, Jul 07, 2017 at 06:33:23AM -0400, Rita wrote: > > yes, i understand that. how come when i submit ten concurrent requests > none > > of them get lost and eventually finish? how is that maintained? > > > > On Fri, Jul 7, 2017 at 3:19 AM, Abdesslem Amri > > wrote: > > > > > Using the simple app.run() from within Flask creates a single > synchronous > > > server on a single thread capable of serving only one client at a time. > > > > > > 2017-07-07 3:02 GMT+02:00 Rita : > > > > > >> Been using flask in my lab for the past few years. It just works. We > > >> recently got some grad students and it seems we are seeing some > slowness in > > >> our flask applications running on Windows 2012 with enthought python. > > >> > > >> currently I am running it in a single threaded mode with nginx ( > > >> http://flask.pocoo.org/docs/0.12/deploying/wsgi-standalone/# > proxy-setups). > > >> My question is: When 2 users hit my flask page, does it get blocked > until > > >> the first user finishes his request - it seems that the case. Is > there a > > >> way to view the "queue" length? How is this queue maintained, or is > it done > > >> by operating system networking stack? > > >> > > >> > > >> > > >> -- > > >> --- Get your facts first, then you can distort them as you please.-- > > >> > > >> _______________________________________________ > > >> Flask mailing list > > >> Flask at python.org > > >> https://mail.python.org/mailman/listinfo/flask > > >> > > >> > > > > > > > > > -- > > > ------------------------------ > > > > > > The preceding message (including attachments) is covered by the > Electronic > > > Communication Privacy Act, 18 U.S.C. sections 2510-2512, is intended > only > > > for the person or entity to which it is addressed, and may contain > > > information that is confidential, protected by attorney-client or other > > > privilege, or otherwise protected from disclosure by law. If you are > not > > > the intended recipient, you are hereby notified that any retention, > > > dissemination, distribution, or copying of this communication is > strictly > > > prohibited. Please reply to the sender that you have received the > message > > > in error and destroy the original message and all copies. > > > > > > _______________________________________________ > > > > > > > > > > > -- > > --- Get your facts first, then you can distort them as you please.-- > > > _______________________________________________ > > Flask mailing list > > Flask at python.org > > https://mail.python.org/mailman/listinfo/flask > > -- --- Get your facts first, then you can distort them as you please.-- -------------- next part -------------- An HTML attachment was scrubbed... URL: From gergely at polonkai.eu Fri Jul 7 08:59:43 2017 From: gergely at polonkai.eu (Gergely Polonkai) Date: Fri, 07 Jul 2017 12:59:43 +0000 Subject: [Flask] flask queue question In-Reply-To: <20170707125423.GG4010@raddish> References: <20170707125423.GG4010@raddish> Message-ID: If you use an HTTP server, like nginx or Apache httpd, the story changes a lot. In that case, it?s the HTTP server that handles the connection and the requests. When the request is received, it is forwarded to the Flask app, usually through a WSGI layer like uWSGI or Apache?s mod_wsgi. On Fri, Jul 7, 2017, 14:54 Adil Hasan wrote: > Hello Rita, > I wonder. Do you think that the nginx server is handling the requests? > I think the webserver is the service that will manage requests. At least > I think that it is. > hth > adil > > On Fri, Jul 07, 2017 at 06:33:23AM -0400, Rita wrote: > > yes, i understand that. how come when i submit ten concurrent requests > none > > of them get lost and eventually finish? how is that maintained? > > > > On Fri, Jul 7, 2017 at 3:19 AM, Abdesslem Amri > > wrote: > > > > > Using the simple app.run() from within Flask creates a single > synchronous > > > server on a single thread capable of serving only one client at a time. > > > > > > 2017-07-07 3:02 GMT+02:00 Rita : > > > > > >> Been using flask in my lab for the past few years. It just works. We > > >> recently got some grad students and it seems we are seeing some > slowness in > > >> our flask applications running on Windows 2012 with enthought python. > > >> > > >> currently I am running it in a single threaded mode with nginx ( > > >> > http://flask.pocoo.org/docs/0.12/deploying/wsgi-standalone/#proxy-setups). > > >> My question is: When 2 users hit my flask page, does it get blocked > until > > >> the first user finishes his request - it seems that the case. Is > there a > > >> way to view the "queue" length? How is this queue maintained, or is > it done > > >> by operating system networking stack? > > >> > > >> > > >> > > >> -- > > >> --- Get your facts first, then you can distort them as you please.-- > > >> > > >> _______________________________________________ > > >> Flask mailing list > > >> Flask at python.org > > >> https://mail.python.org/mailman/listinfo/flask > > >> > > >> > > > > > > > > > -- > > > ------------------------------ > > > > > > The preceding message (including attachments) is covered by the > Electronic > > > Communication Privacy Act, 18 U.S.C. sections 2510-2512, is intended > only > > > for the person or entity to which it is addressed, and may contain > > > information that is confidential, protected by attorney-client or other > > > privilege, or otherwise protected from disclosure by law. If you are > not > > > the intended recipient, you are hereby notified that any retention, > > > dissemination, distribution, or copying of this communication is > strictly > > > prohibited. Please reply to the sender that you have received the > message > > > in error and destroy the original message and all copies. > > > > > > _______________________________________________ > > > > > > > > > > > -- > > --- Get your facts first, then you can distort them as you please.-- > > > _______________________________________________ > > Flask mailing list > > Flask at python.org > > https://mail.python.org/mailman/listinfo/flask > > _______________________________________________ > Flask mailing list > Flask at python.org > https://mail.python.org/mailman/listinfo/flask > -------------- next part -------------- An HTML attachment was scrubbed... URL: From paradox2005 at gmail.com Fri Jul 7 09:07:10 2017 From: paradox2005 at gmail.com (Adil Hasan) Date: Fri, 7 Jul 2017 14:07:10 +0100 Subject: [Flask] flask queue question In-Reply-To: References: <20170707125423.GG4010@raddish> Message-ID: <20170707130708.GH4010@raddish> Hello Rita, I'm afraid I'm not familiar with Windows. I noticed you're running nginx in single-threaded mode. I think you may be able to configure the number of workers so you can have more requests handled at one time. I'm afraid I've not used nginx yet (I really should have a bash at it), but I am certain more able people on this list will be able to help you. I very much hope your day goes well, adil On Fri, Jul 07, 2017 at 08:56:59AM -0400, Rita wrote: > yeah, my traffic is going thru nginx. Its acting as a proxy. Can you > recommend a good wsgi server for windows? > > On Fri, Jul 7, 2017 at 8:54 AM, Adil Hasan wrote: > > > Hello Rita, > > I wonder. Do you think that the nginx server is handling the requests? > > I think the webserver is the service that will manage requests. At least > > I think that it is. > > hth > > adil > > > > On Fri, Jul 07, 2017 at 06:33:23AM -0400, Rita wrote: > > > yes, i understand that. how come when i submit ten concurrent requests > > none > > > of them get lost and eventually finish? how is that maintained? > > > > > > On Fri, Jul 7, 2017 at 3:19 AM, Abdesslem Amri > > > wrote: > > > > > > > Using the simple app.run() from within Flask creates a single > > synchronous > > > > server on a single thread capable of serving only one client at a time. > > > > > > > > 2017-07-07 3:02 GMT+02:00 Rita : > > > > > > > >> Been using flask in my lab for the past few years. It just works. We > > > >> recently got some grad students and it seems we are seeing some > > slowness in > > > >> our flask applications running on Windows 2012 with enthought python. > > > >> > > > >> currently I am running it in a single threaded mode with nginx ( > > > >> http://flask.pocoo.org/docs/0.12/deploying/wsgi-standalone/# > > proxy-setups). > > > >> My question is: When 2 users hit my flask page, does it get blocked > > until > > > >> the first user finishes his request - it seems that the case. Is > > there a > > > >> way to view the "queue" length? How is this queue maintained, or is > > it done > > > >> by operating system networking stack? > > > >> > > > >> > > > >> > > > >> -- > > > >> --- Get your facts first, then you can distort them as you please.-- > > > >> > > > >> _______________________________________________ > > > >> Flask mailing list > > > >> Flask at python.org > > > >> https://mail.python.org/mailman/listinfo/flask > > > >> > > > >> > > > > > > > > > > > > -- > > > > ------------------------------ > > > > > > > > The preceding message (including attachments) is covered by the > > Electronic > > > > Communication Privacy Act, 18 U.S.C. sections 2510-2512, is intended > > only > > > > for the person or entity to which it is addressed, and may contain > > > > information that is confidential, protected by attorney-client or other > > > > privilege, or otherwise protected from disclosure by law. If you are > > not > > > > the intended recipient, you are hereby notified that any retention, > > > > dissemination, distribution, or copying of this communication is > > strictly > > > > prohibited. Please reply to the sender that you have received the > > message > > > > in error and destroy the original message and all copies. > > > > > > > > _______________________________________________ > > > > > > > > > > > > > > > > -- > > > --- Get your facts first, then you can distort them as you please.-- > > > > > _______________________________________________ > > > Flask mailing list > > > Flask at python.org > > > https://mail.python.org/mailman/listinfo/flask > > > > > > > -- > --- Get your facts first, then you can distort them as you please.-- From rmorgan466 at gmail.com Fri Jul 7 09:35:57 2017 From: rmorgan466 at gmail.com (Rita) Date: Fri, 7 Jul 2017 09:35:57 -0400 Subject: [Flask] flask queue question In-Reply-To: References: <20170707125423.GG4010@raddish> Message-ID: Right, when the client makes a request it gets forward to flask app. But the flask app is syncrnous so it will wait a long time. Ideally, I am looking for a good uWSGI (high performance) on Windows. On Fri, Jul 7, 2017 at 8:59 AM, Gergely Polonkai wrote: > If you use an HTTP server, like nginx or Apache httpd, the story changes a > lot. In that case, it?s the HTTP server that handles the connection and the > requests. When the request is received, it is forwarded to the Flask app, > usually through a WSGI layer like uWSGI or Apache?s mod_wsgi. > > On Fri, Jul 7, 2017, 14:54 Adil Hasan wrote: > >> Hello Rita, >> I wonder. Do you think that the nginx server is handling the requests? >> I think the webserver is the service that will manage requests. At least >> I think that it is. >> hth >> adil >> >> On Fri, Jul 07, 2017 at 06:33:23AM -0400, Rita wrote: >> > yes, i understand that. how come when i submit ten concurrent requests >> none >> > of them get lost and eventually finish? how is that maintained? >> > >> > On Fri, Jul 7, 2017 at 3:19 AM, Abdesslem Amri > > >> > wrote: >> > >> > > Using the simple app.run() from within Flask creates a single >> synchronous >> > > server on a single thread capable of serving only one client at a >> time. >> > > >> > > 2017-07-07 3:02 GMT+02:00 Rita : >> > > >> > >> Been using flask in my lab for the past few years. It just works. We >> > >> recently got some grad students and it seems we are seeing some >> slowness in >> > >> our flask applications running on Windows 2012 with enthought python. >> > >> >> > >> currently I am running it in a single threaded mode with nginx ( >> > >> http://flask.pocoo.org/docs/0.12/deploying/wsgi-standalone/# >> proxy-setups). >> > >> My question is: When 2 users hit my flask page, does it get blocked >> until >> > >> the first user finishes his request - it seems that the case. Is >> there a >> > >> way to view the "queue" length? How is this queue maintained, or is >> it done >> > >> by operating system networking stack? >> > >> >> > >> >> > >> >> > >> -- >> > >> --- Get your facts first, then you can distort them as you please.-- >> > >> >> > >> _______________________________________________ >> > >> Flask mailing list >> > >> Flask at python.org >> > >> https://mail.python.org/mailman/listinfo/flask >> > >> >> > >> >> > > >> > > >> > > -- >> > > ------------------------------ >> > > >> > > The preceding message (including attachments) is covered by the >> Electronic >> > > Communication Privacy Act, 18 U.S.C. sections 2510-2512, is intended >> only >> > > for the person or entity to which it is addressed, and may contain >> > > information that is confidential, protected by attorney-client or >> other >> > > privilege, or otherwise protected from disclosure by law. If you are >> not >> > > the intended recipient, you are hereby notified that any retention, >> > > dissemination, distribution, or copying of this communication is >> strictly >> > > prohibited. Please reply to the sender that you have received the >> message >> > > in error and destroy the original message and all copies. >> > > >> > > _______________________________________________ >> > > >> > >> > >> > >> > -- >> > --- Get your facts first, then you can distort them as you please.-- >> >> > _______________________________________________ >> > Flask mailing list >> > Flask at python.org >> > https://mail.python.org/mailman/listinfo/flask >> >> _______________________________________________ >> Flask mailing list >> Flask at python.org >> https://mail.python.org/mailman/listinfo/flask >> > -- --- Get your facts first, then you can distort them as you please.-- -------------- next part -------------- An HTML attachment was scrubbed... URL: From coreybrett at gmail.com Fri Jul 7 09:57:38 2017 From: coreybrett at gmail.com (Corey Boyle) Date: Fri, 7 Jul 2017 09:57:38 -0400 Subject: [Flask] flask queue question In-Reply-To: References: <20170707125423.GG4010@raddish> Message-ID: mod_wsgi might be an option for you if you are willing to use Apache. https://github.com/GrahamDumpleton/mod_wsgi/blob/develop/win32/README.rst Otherwise, you might be better off setting up a Linux box. __ Corey On Jul 7, 2017 9:43 AM, "Rita" wrote: > Right, when the client makes a request it gets forward to flask app. But > the flask app is syncrnous so it will wait a long time. Ideally, I am > looking for a good uWSGI (high performance) on Windows. > > On Fri, Jul 7, 2017 at 8:59 AM, Gergely Polonkai > wrote: > >> If you use an HTTP server, like nginx or Apache httpd, the story changes >> a lot. In that case, it?s the HTTP server that handles the connection and >> the requests. When the request is received, it is forwarded to the Flask >> app, usually through a WSGI layer like uWSGI or Apache?s mod_wsgi. >> >> On Fri, Jul 7, 2017, 14:54 Adil Hasan wrote: >> >>> Hello Rita, >>> I wonder. Do you think that the nginx server is handling the requests? >>> I think the webserver is the service that will manage requests. At least >>> I think that it is. >>> hth >>> adil >>> >>> On Fri, Jul 07, 2017 at 06:33:23AM -0400, Rita wrote: >>> > yes, i understand that. how come when i submit ten concurrent requests >>> none >>> > of them get lost and eventually finish? how is that maintained? >>> > >>> > On Fri, Jul 7, 2017 at 3:19 AM, Abdesslem Amri < >>> amriabdesslem at gmail.com> >>> > wrote: >>> > >>> > > Using the simple app.run() from within Flask creates a single >>> synchronous >>> > > server on a single thread capable of serving only one client at a >>> time. >>> > > >>> > > 2017-07-07 3:02 GMT+02:00 Rita : >>> > > >>> > >> Been using flask in my lab for the past few years. It just works. We >>> > >> recently got some grad students and it seems we are seeing some >>> slowness in >>> > >> our flask applications running on Windows 2012 with enthought >>> python. >>> > >> >>> > >> currently I am running it in a single threaded mode with nginx ( >>> > >> http://flask.pocoo.org/docs/0.12/deploying/wsgi-standalone/# >>> proxy-setups). >>> > >> My question is: When 2 users hit my flask page, does it get blocked >>> until >>> > >> the first user finishes his request - it seems that the case. Is >>> there a >>> > >> way to view the "queue" length? How is this queue maintained, or is >>> it done >>> > >> by operating system networking stack? >>> > >> >>> > >> >>> > >> >>> > >> -- >>> > >> --- Get your facts first, then you can distort them as you please.-- >>> > >> >>> > >> _______________________________________________ >>> > >> Flask mailing list >>> > >> Flask at python.org >>> > >> https://mail.python.org/mailman/listinfo/flask >>> > >> >>> > >> >>> > > >>> > > >>> > > -- >>> > > ------------------------------ >>> > > >>> > > The preceding message (including attachments) is covered by the >>> Electronic >>> > > Communication Privacy Act, 18 U.S.C. sections 2510-2512, is intended >>> only >>> > > for the person or entity to which it is addressed, and may contain >>> > > information that is confidential, protected by attorney-client or >>> other >>> > > privilege, or otherwise protected from disclosure by law. If you are >>> not >>> > > the intended recipient, you are hereby notified that any retention, >>> > > dissemination, distribution, or copying of this communication is >>> strictly >>> > > prohibited. Please reply to the sender that you have received the >>> message >>> > > in error and destroy the original message and all copies. >>> > > >>> > > _______________________________________________ >>> > > >>> > >>> > >>> > >>> > -- >>> > --- Get your facts first, then you can distort them as you please.-- >>> >>> > _______________________________________________ >>> > Flask mailing list >>> > Flask at python.org >>> > https://mail.python.org/mailman/listinfo/flask >>> >>> _______________________________________________ >>> Flask mailing list >>> Flask at python.org >>> https://mail.python.org/mailman/listinfo/flask >>> >> > > > -- > --- Get your facts first, then you can distort them as you please.-- > > _______________________________________________ > Flask mailing list > Flask at python.org > https://mail.python.org/mailman/listinfo/flask > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From coreybrett at gmail.com Fri Jul 7 18:51:12 2017 From: coreybrett at gmail.com (Corey Boyle) Date: Fri, 7 Jul 2017 18:51:12 -0400 Subject: [Flask] flask queue question In-Reply-To: References: <20170707125423.GG4010@raddish> Message-ID: Rita, I found the following article about deploying Django on IIS, purhaps you could adapt it to your needs. https://www.toptal.com/django/installing-django-on-iis-a-step-by-step-tutorial __ Corey On Jul 7, 2017 9:57 AM, "Corey Boyle" wrote: > mod_wsgi might be an option for you if you are willing to use Apache. > > https://github.com/GrahamDumpleton/mod_wsgi/blob/develop/win32/README.rst > > Otherwise, you might be better off setting up a Linux box. > > __ > Corey > > On Jul 7, 2017 9:43 AM, "Rita" wrote: > >> Right, when the client makes a request it gets forward to flask app. But >> the flask app is syncrnous so it will wait a long time. Ideally, I am >> looking for a good uWSGI (high performance) on Windows. >> >> On Fri, Jul 7, 2017 at 8:59 AM, Gergely Polonkai >> wrote: >> >>> If you use an HTTP server, like nginx or Apache httpd, the story changes >>> a lot. In that case, it?s the HTTP server that handles the connection and >>> the requests. When the request is received, it is forwarded to the Flask >>> app, usually through a WSGI layer like uWSGI or Apache?s mod_wsgi. >>> >>> On Fri, Jul 7, 2017, 14:54 Adil Hasan wrote: >>> >>>> Hello Rita, >>>> I wonder. Do you think that the nginx server is handling the requests? >>>> I think the webserver is the service that will manage requests. At least >>>> I think that it is. >>>> hth >>>> adil >>>> >>>> On Fri, Jul 07, 2017 at 06:33:23AM -0400, Rita wrote: >>>> > yes, i understand that. how come when i submit ten concurrent >>>> requests none >>>> > of them get lost and eventually finish? how is that maintained? >>>> > >>>> > On Fri, Jul 7, 2017 at 3:19 AM, Abdesslem Amri < >>>> amriabdesslem at gmail.com> >>>> > wrote: >>>> > >>>> > > Using the simple app.run() from within Flask creates a single >>>> synchronous >>>> > > server on a single thread capable of serving only one client at a >>>> time. >>>> > > >>>> > > 2017-07-07 3:02 GMT+02:00 Rita : >>>> > > >>>> > >> Been using flask in my lab for the past few years. It just works. >>>> We >>>> > >> recently got some grad students and it seems we are seeing some >>>> slowness in >>>> > >> our flask applications running on Windows 2012 with enthought >>>> python. >>>> > >> >>>> > >> currently I am running it in a single threaded mode with nginx ( >>>> > >> http://flask.pocoo.org/docs/0.12/deploying/wsgi-standalone/# >>>> proxy-setups). >>>> > >> My question is: When 2 users hit my flask page, does it get >>>> blocked until >>>> > >> the first user finishes his request - it seems that the case. Is >>>> there a >>>> > >> way to view the "queue" length? How is this queue maintained, or >>>> is it done >>>> > >> by operating system networking stack? >>>> > >> >>>> > >> >>>> > >> >>>> > >> -- >>>> > >> --- Get your facts first, then you can distort them as you >>>> please.-- >>>> > >> >>>> > >> _______________________________________________ >>>> > >> Flask mailing list >>>> > >> Flask at python.org >>>> > >> https://mail.python.org/mailman/listinfo/flask >>>> > >> >>>> > >> >>>> > > >>>> > > >>>> > > -- >>>> > > ------------------------------ >>>> > > >>>> > > The preceding message (including attachments) is covered by the >>>> Electronic >>>> > > Communication Privacy Act, 18 U.S.C. sections 2510-2512, is >>>> intended only >>>> > > for the person or entity to which it is addressed, and may contain >>>> > > information that is confidential, protected by attorney-client or >>>> other >>>> > > privilege, or otherwise protected from disclosure by law. If you >>>> are not >>>> > > the intended recipient, you are hereby notified that any retention, >>>> > > dissemination, distribution, or copying of this communication is >>>> strictly >>>> > > prohibited. Please reply to the sender that you have received the >>>> message >>>> > > in error and destroy the original message and all copies. >>>> > > >>>> > > _______________________________________________ >>>> > > >>>> > >>>> > >>>> > >>>> > -- >>>> > --- Get your facts first, then you can distort them as you please.-- >>>> >>>> > _______________________________________________ >>>> > Flask mailing list >>>> > Flask at python.org >>>> > https://mail.python.org/mailman/listinfo/flask >>>> >>>> _______________________________________________ >>>> Flask mailing list >>>> Flask at python.org >>>> https://mail.python.org/mailman/listinfo/flask >>>> >>> >> >> >> -- >> --- Get your facts first, then you can distort them as you please.-- >> >> _______________________________________________ >> Flask mailing list >> Flask at python.org >> https://mail.python.org/mailman/listinfo/flask >> >> -------------- next part -------------- An HTML attachment was scrubbed... URL: From bdeluca at gmail.com Sun Jul 9 09:32:21 2017 From: bdeluca at gmail.com (Ben De Luca) Date: Sun, 09 Jul 2017 13:32:21 +0000 Subject: [Flask] flask queue question In-Reply-To: References: <20170707125423.GG4010@raddish> Message-ID: Docker would be very easy. It's how we deploy our software on lin/win/Mac. Don't have to think about what platform we are on then it's always Linux. On Sat, 8 Jul 2017 at 1:51 am, Corey Boyle wrote: > Rita, > > I found the following article about deploying Django on IIS, purhaps you > could adapt it to your needs. > > > https://www.toptal.com/django/installing-django-on-iis-a-step-by-step-tutorial > > > > > __ > > Corey > > On Jul 7, 2017 9:57 AM, "Corey Boyle" wrote: > >> mod_wsgi might be an option for you if you are willing to use Apache. >> >> https://github.com/GrahamDumpleton/mod_wsgi/blob/develop/win32/README.rst >> >> Otherwise, you might be better off setting up a Linux box. >> >> __ >> Corey >> >> On Jul 7, 2017 9:43 AM, "Rita" wrote: >> >>> Right, when the client makes a request it gets forward to flask app. But >>> the flask app is syncrnous so it will wait a long time. Ideally, I am >>> looking for a good uWSGI (high performance) on Windows. >>> >>> On Fri, Jul 7, 2017 at 8:59 AM, Gergely Polonkai >>> wrote: >>> >>>> If you use an HTTP server, like nginx or Apache httpd, the story >>>> changes a lot. In that case, it?s the HTTP server that handles the >>>> connection and the requests. When the request is received, it is forwarded >>>> to the Flask app, usually through a WSGI layer like uWSGI or Apache?s >>>> mod_wsgi. >>>> >>>> On Fri, Jul 7, 2017, 14:54 Adil Hasan wrote: >>>> >>>>> Hello Rita, >>>>> I wonder. Do you think that the nginx server is handling the requests? >>>>> I think the webserver is the service that will manage requests. At >>>>> least >>>>> I think that it is. >>>>> hth >>>>> adil >>>>> >>>>> On Fri, Jul 07, 2017 at 06:33:23AM -0400, Rita wrote: >>>>> > yes, i understand that. how come when i submit ten concurrent >>>>> requests none >>>>> > of them get lost and eventually finish? how is that maintained? >>>>> > >>>>> > On Fri, Jul 7, 2017 at 3:19 AM, Abdesslem Amri < >>>>> amriabdesslem at gmail.com> >>>>> > wrote: >>>>> > >>>>> > > Using the simple app.run() from within Flask creates a single >>>>> synchronous >>>>> > > server on a single thread capable of serving only one client at a >>>>> time. >>>>> > > >>>>> > > 2017-07-07 3:02 GMT+02:00 Rita : >>>>> > > >>>>> > >> Been using flask in my lab for the past few years. It just works. >>>>> We >>>>> > >> recently got some grad students and it seems we are seeing some >>>>> slowness in >>>>> > >> our flask applications running on Windows 2012 with enthought >>>>> python. >>>>> > >> >>>>> > >> currently I am running it in a single threaded mode with nginx ( >>>>> > >> >>>>> http://flask.pocoo.org/docs/0.12/deploying/wsgi-standalone/#proxy-setups >>>>> ). >>>>> > >> My question is: When 2 users hit my flask page, does it get >>>>> blocked until >>>>> > >> the first user finishes his request - it seems that the case. Is >>>>> there a >>>>> > >> way to view the "queue" length? How is this queue maintained, or >>>>> is it done >>>>> > >> by operating system networking stack? >>>>> > >> >>>>> > >> >>>>> > >> >>>>> > >> -- >>>>> > >> --- Get your facts first, then you can distort them as you >>>>> please.-- >>>>> > >> >>>>> > >> _______________________________________________ >>>>> > >> Flask mailing list >>>>> > >> Flask at python.org >>>>> > >> https://mail.python.org/mailman/listinfo/flask >>>>> > >> >>>>> > >> >>>>> > > >>>>> > > >>>>> > > -- >>>>> > > ------------------------------ >>>>> > > >>>>> > > The preceding message (including attachments) is covered by the >>>>> Electronic >>>>> > > Communication Privacy Act, 18 U.S.C. sections 2510-2512, is >>>>> intended only >>>>> > > for the person or entity to which it is addressed, and may contain >>>>> > > information that is confidential, protected by attorney-client or >>>>> other >>>>> > > privilege, or otherwise protected from disclosure by law. If you >>>>> are not >>>>> > > the intended recipient, you are hereby notified that any retention, >>>>> > > dissemination, distribution, or copying of this communication is >>>>> strictly >>>>> > > prohibited. Please reply to the sender that you have received the >>>>> message >>>>> > > in error and destroy the original message and all copies. >>>>> > > >>>>> > > _______________________________________________ >>>>> > > >>>>> > >>>>> > >>>>> > >>>>> > -- >>>>> > --- Get your facts first, then you can distort them as you please.-- >>>>> >>>>> > _______________________________________________ >>>>> > Flask mailing list >>>>> > Flask at python.org >>>>> > https://mail.python.org/mailman/listinfo/flask >>>>> >>>>> _______________________________________________ >>>>> Flask mailing list >>>>> Flask at python.org >>>>> https://mail.python.org/mailman/listinfo/flask >>>>> >>>> >>> >>> >>> -- >>> --- Get your facts first, then you can distort them as you please.-- >>> >>> _______________________________________________ >>> Flask mailing list >>> Flask at python.org >>> https://mail.python.org/mailman/listinfo/flask >>> >>> _______________________________________________ > Flask mailing list > Flask at python.org > https://mail.python.org/mailman/listinfo/flask > -------------- next part -------------- An HTML attachment was scrubbed... URL: From deepakpjose at gmail.com Mon Jul 10 04:10:45 2017 From: deepakpjose at gmail.com (Deepak Jose) Date: Mon, 10 Jul 2017 13:40:45 +0530 Subject: [Flask] Why flask.run() is not for production environment Message-ID: Hi Team, Can someone explain me why run() is not good for production environment? All the examples I have seen for flask use run. Can someone help me to understand why it is not recommended and how we have to deploy our app then? The :ref:'deployment' can be found where? Excerpts from flask documentation for run: def run(self, host=None, port=None, debug=None, **options): """Runs the application on a local development server. *Do not use ``run()`` in a production setting. It is not intended to* *meet security and performance requirements for a production server.* *Instead, see :ref:`deployment` for WSGI server recommendations.*Thanks, Deepak -------------- next part -------------- An HTML attachment was scrubbed... URL: From me at samuelharmer.com Mon Jul 10 04:19:22 2017 From: me at samuelharmer.com (Samuel Harmer) Date: Mon, 10 Jul 2017 09:19:22 +0100 Subject: [Flask] Why flask.run() is not for production environment In-Reply-To: References: Message-ID: Dear Deepak, A quick Google for "flask deployment wsgi" gets you to http://flask.pocoo.org/docs/0.12/deploying/ which describes a number of options. In short, serving fast and safe HTTP to the www is a significant challenge. `.run()` works but has not had the same effort put into www engineering than dedicated web server projects have. Kind regards, Samuel Harmer On 10 July 2017 at 09:10, Deepak Jose wrote: > Hi Team, > > Can someone explain me why run() is not good for production environment? > All the examples I have seen for flask use run. Can someone help me to > understand why it is not recommended and > how we have to deploy our app then? The :ref:'deployment' can be found > where? > > Excerpts from flask documentation for run: > > def run(self, host=None, port=None, debug=None, **options): > """Runs the application on a local development server. > > *Do not use ``run()`` in a production setting. It is not intended to* > *meet security and performance requirements for a production server.* > > > *Instead, see :ref:`deployment` for WSGI server recommendations.*Thanks, > Deepak > > _______________________________________________ > Flask mailing list > Flask at python.org > https://mail.python.org/mailman/listinfo/flask > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From gergely at polonkai.eu Wed Jul 12 10:52:18 2017 From: gergely at polonkai.eu (Gergely Polonkai) Date: Wed, 12 Jul 2017 14:52:18 +0000 Subject: [Flask] Flask Extension Development In-Reply-To: References: Message-ID: Hello Alena, I just stumbled upon a library: Flask-JSGlue. This does pretty much what you want to achieve, although it doesn?t do any filtering (so it exposes everything). Maybe you should expand this instead of writing a new one. Best, Gergely Alena Lifar ezt ?rta (id?pont: 2017. j?l. 5., Sze, 11:36): > Hi Gergely, > > I completely agree that exposing all routes without an option of hiding > some of them is a no-go. In my package you can use private() decorator func > in order to hide either a route or a Blueprint. I have put some examples in > the Readme: > > @private()@app.route('/restricted_route/')def private_endpoint(): > return 'Hello Private Endpoint' > > > As well as Blueprints: > > # or: app_bp = private(Blueprint('my_bp', __name__)) > app_bp = Blueprint('my_bp', __name__) > private(app_bp) > > > Does it correlate to your suggestion? > > My vision of requests with parameters was to just put those in the > available url string as is (just like they were put in route()): > > "hello_world": { // name of a public endpoint > "active_urls": [ > "/", > "/health_check//" > ], > "methods": [ > "GET", > "HEAD", > "OPTIONS" > ] > }, > > > By providing more information like required param format or an example of > response format for a given route I think I'd create a vulnerability. I > think that everything about data formats has to be in the API docs. This > extension aimed to get rid of hardcoded api urls in the components/client > code mostly... > > Please, let me know what you think. > > P.S. I'm quite new to contributing something valuable to the open-source. > Could you please suggest me any resources that I might share my work with? > > Thank you for your help and for the feedback. > > Kind regards, > Alena > > On Wed, Jul 5, 2017 at 11:34 AM, Alena Lifar > wrote: > >> Hi Abdesslem, >> >> Awesome, thanks! >> >> Kind regards, >> Alena >> >> On Wed, Jul 5, 2017 at 9:31 AM, Abdesslem Amri >> wrote: >> >>> Hi, >>> >>> To add a new extension. you have to make a pull request to >>> https://github.com/pallets/flask-website. >>> >>> Best regards, >>> Abdesslem Amri >>> >> >>> 2017-07-04 22:45 GMT+02:00 Alena Lifar : >>> >>>> Hello everyone, >>>> >>>> My name is Alena and I have been working on a Flask Extension that >>>> collects and exposes routes declared in your Flask application/Blueprint >>>> via REST. >>>> >>>> Here is Github project: >>>> https://github.com/UseTheApi/flask_url_discovery >>>> >>>> Could anyone please take a look and let me know if this could be >>>> useful? Do you think it has a chance to be added into Flask Extension >>>> Registry? Is there anything I have to improve? >>>> >>>> I have found this link: >>>> http://librelist.com/browser/flask/2010/7/25/flask-extension-review-status/ which >>>> points to http://github.com/mitsuhiko/flask/tree/master/extreview/ for >>>> Flask Extensions review and approval but this link is dead. >>>> >>>> Thank you for your time. >>>> >>>> Kind regards, >>>> Alena >>>> >>>> _______________________________________________ >>>> Flask mailing list >>>> Flask at python.org >>>> https://mail.python.org/mailman/listinfo/flask >>>> >>>> >>> >>> >>> -- >>> ------------------------------ >>> >>> The preceding message (including attachments) is covered by the >>> Electronic Communication Privacy Act, 18 U.S.C. sections 2510-2512, is >>> intended only for the person or entity to which it is addressed, and may >>> contain information that is confidential, protected by attorney-client or >>> other privilege, or otherwise protected from disclosure by law. If you are >>> not the intended recipient, you are hereby notified that any retention, >>> dissemination, distribution, or copying of this communication is strictly >>> prohibited. Please reply to the sender that you have received the message >>> in error and destroy the original message and all copies. >>> >>> _______________________________________________ >>> >> >> > -------------- next part -------------- An HTML attachment was scrubbed... URL: From jgabriele at fastmail.fm Mon Jul 17 14:58:06 2017 From: jgabriele at fastmail.fm (John Gabriele) Date: Mon, 17 Jul 2017 14:58:06 -0400 Subject: [Flask] Tutorial, step 3: Installing flaskr as a package. Why? Message-ID: <1500317886.2904836.1043757464.58204BE8@webmail.messagingengine.com> Hi, Reading the tutorial docs for Flask, I'm confused about step 3 of the tutorial: [Installing flaskr as a package](http://flask.pocoo.org/docs/0.12/tutorial/packaging/). This step describes using setuptools to install my little webapp package into my project's venv. Why would I want to do that? I can already run my webapp without installing it --- it's just `flask run`. Why does this part of the tutorial want me to install my webapp into my project's venv? Thanks, -- John From gergely at polonkai.eu Tue Jul 18 03:01:35 2017 From: gergely at polonkai.eu (Gergely Polonkai) Date: Tue, 18 Jul 2017 07:01:35 +0000 Subject: [Flask] Tutorial, step 3: Installing flaskr as a package. Why? In-Reply-To: <1500317886.2904836.1043757464.58204BE8@webmail.messagingengine.com> References: <1500317886.2904836.1043757464.58204BE8@webmail.messagingengine.com> Message-ID: Actually, you don't have to. If you are creating a Flask based web application, that will be run just by you, you can completely omit this step. However, if you are developing a Flask extension, and you want others to use it, it's much easier for them to download it as a Python package. Best, Gergely On Mon, Jul 17, 2017, 20:58 John Gabriele wrote: > Hi, > > Reading the tutorial docs for Flask, I'm confused about step 3 of the > tutorial: [Installing flaskr as a > package](http://flask.pocoo.org/docs/0.12/tutorial/packaging/). This > step describes using setuptools to install my little webapp package into > my project's venv. Why would I want to do that? I can already run my > webapp without installing it --- it's just `flask run`. Why does this > part of the tutorial want me to install my webapp into my project's > venv? > > Thanks, > -- John > _______________________________________________ > Flask mailing list > Flask at python.org > https://mail.python.org/mailman/listinfo/flask > -------------- next part -------------- An HTML attachment was scrubbed... URL: From jgabriele at fastmail.fm Tue Jul 18 10:38:26 2017 From: jgabriele at fastmail.fm (John Gabriele) Date: Tue, 18 Jul 2017 10:38:26 -0400 Subject: [Flask] Tutorial, step 3: Installing flaskr as a package. Why? In-Reply-To: References: <1500317886.2904836.1043757464.58204BE8@webmail.messagingengine.com> Message-ID: <1500388706.4046314.1044690760.43FB0923@webmail.messagingengine.com> Thanks, Gergely. Created . On Tue, Jul 18, 2017, at 03:01 AM, Gergely Polonkai wrote: > Actually, you don't have to. If you are creating a Flask based web application, that will be run just by you, you can completely omit this step.> However, if you are developing a Flask extension, and you want others to use it, it's much easier for them to download it as a Python package.> Best, > Gergely > > On Mon, Jul 17, 2017, 20:58 John Gabriele wrote:>> Hi, >> >> Reading the tutorial docs for Flask, I'm confused about step 3 of the>> tutorial: [Installing flaskr as a >> package](http://flask.pocoo.org/docs/0.12/tutorial/packaging/). This>> step describes using setuptools to install my little webapp package into>> my project's venv. Why would I want to do that? I can already run my>> webapp without installing it --- it's just `flask run`. Why does this>> part of the tutorial want me to install my webapp into my project's>> venv? >> >> Thanks, >> -- John >> _______________________________________________ >> Flask mailing list >> Flask at python.org >> https://mail.python.org/mailman/listinfo/flask -------------- next part -------------- An HTML attachment was scrubbed... URL: From gergely at polonkai.eu Wed Jul 19 04:40:43 2017 From: gergely at polonkai.eu (Gergely Polonkai) Date: Wed, 19 Jul 2017 08:40:43 +0000 Subject: [Flask] Ignored TypeError when my app is terminated Message-ID: Hello, this is half Python, half Flask question. I have a relatively big Flask app (closed source, but I can share bits of the code if needed). It uses Celery, which I suspect as the source of my problem (I think it started appearing when we began using it). I have a relatively complex manage.py script, which utilizes Flask-Script. At some, seemingly random, occasions, I get the following traceback when a command finishes: Exception ignored in: .remove at 0x7f8f4fd2df28> Traceback (most recent call last): File "/usr/lib64/python3.5/weakref.py", line 117, in remove TypeError: 'NoneType' object is not callable Exception ignored in: .remove at 0x7f8f4fd2df28> Traceback (most recent call last): File "/usr/lib64/python3.5/weakref.py", line 117, in remove TypeError: 'NoneType' object is not callable I know such ignored exceptions can happen after a script exits, while Python is destructing all the objects in memory. However, with such a stack trace, it?s pretty hard to find what is exactly causing the problem. Do any of you have an idea how to get to the bottom of this? Best, Gergely -------------- next part -------------- An HTML attachment was scrubbed... URL: From jgabriele at fastmail.fm Thu Jul 20 12:14:09 2017 From: jgabriele at fastmail.fm (John Gabriele) Date: Thu, 20 Jul 2017 12:14:09 -0400 Subject: [Flask] help getting hello world package-based webapp running without installing it Message-ID: <1500567249.3242685.1047249344.36AA1C1D@webmail.messagingengine.com> I'd like to get a simple hello-world Flask webapp running --- without installing it yet --- but am having trouble. This is a package-based webapp, as outlined in the Flask tutorial (like flaskr). I've created: my-proj/ my-env/ # a venv with flask installed README.txt my_webapp/ __init__.py # empty my_webapp.py static/ style.css templates/ my_webapp.py looks like: ~~~ from flask import Flask app = Flask('my_webapp') @app.route('/') def index(): return "Hi" ~~~ I have the venv activated. My relevant environment variables are set: FLASK_APP=my_webapp.my_webapp FLASK_DEBUG=true I was hoping to get this simplest case working, without adding anything to __init__.py, and without installing my webapp package. I'd like to run it on its dev server while developing. I can install/deploy later. It's my understanding that this is the customary way to develop locally with Flask. In my-proj directory, and with my venv activated, if I try `flask run`, it will run, ~~~ (my-env) my-proj$ flask run * Serving Flask app "my_webapp.my_webapp" * Forcing debug mode on * Running on http://127.0.0.1:5000/ (Press CTRL+C to quit) * Restarting with stat * Debugger is active! * Debugger PIN: 924-462-254 ~~~ but then when I access localhost:5000/ (which strips that last slash after hit Enter), I get: | flask.cli.NoAppException: The file/path provided (my_webapp.my_webapp) does | not appear to exist. Please verify the path is correct. If app is not on PYTHONPATH, | ensure the extension is .py One thing that *does* work: if I instead run via `python -m flask run`, I get ~~~ (my-env) my-proj$ python -m flask run * Serving Flask app "my_webapp.my_webapp" * Forcing debug mode on * Running on http://127.0.0.1:5000/ (Press CTRL+C to quit) * Restarting with stat /usr/lib/python3.5/runpy.py:125: RuntimeWarning: 'flask.cli' found in sys.modules after import of package 'flask', but prior to execution of 'flask.cli'; this may result in unpredictable behaviour warn(RuntimeWarning(msg)) * Debugger is active! * Debugger PIN: 152-420-413 ~~~ and I can load the page and it works. Why does that work but not plain `flask run`? Is something wrong in my `app = Flask(...)` arg, or in my env vars? Is this the customary way to set up a Flask webapp (as a package) and run it from the project directory? Thanks! -- John From davidism at gmail.com Thu Jul 20 12:27:19 2017 From: davidism at gmail.com (David Lord) Date: Thu, 20 Jul 2017 09:27:19 -0700 Subject: [Flask] help getting hello world package-based webapp running without installing it In-Reply-To: <1500567249.3242685.1047249344.36AA1C1D@webmail.messagingengine.com> References: <1500567249.3242685.1047249344.36AA1C1D@webmail.messagingengine.com> Message-ID: The correct way to develop your application is by installing it as a package, that's not just something for production, and it's why the tutorial tells you to do it. The next release of Flask will allow `FLASK_APP=package.inner` for some non-installed cases, but it's better to just install the package. It works with `python -m flask` because that implicitly adds the current directory to the Python path, which is not something to rely on. For example, it would break if you ran from a different directory. Installing the package is not a big task, you create a `setup.py` file with a couple lines then do `pip install -e .`. -------------- next part -------------- An HTML attachment was scrubbed... URL: From jgabriele at fastmail.fm Thu Jul 20 12:43:36 2017 From: jgabriele at fastmail.fm (John Gabriele) Date: Thu, 20 Jul 2017 12:43:36 -0400 Subject: [Flask] help getting hello world package-based webapp running without installing it In-Reply-To: References: <1500567249.3242685.1047249344.36AA1C1D@webmail.messagingengine.com> Message-ID: <1500569016.3248468.1047290272.5984EBD1@webmail.messagingengine.com> On Thu, Jul 20, 2017, at 12:27 PM, David Lord wrote: > The correct way to develop your application is by installing it as a package, that's not just something for production, Ah! I understand now. And the `pip install --editable .` enables the installed package reloading --- had to re-read that part. Thanks! -- John -------------- next part -------------- An HTML attachment was scrubbed... URL: From thomas.david.vaughan at gmail.com Thu Jul 27 00:51:32 2017 From: thomas.david.vaughan at gmail.com (Tom Vaughan) Date: Thu, 27 Jul 2017 00:51:32 -0400 Subject: [Flask] Cannot get custom header value from request.headers Message-ID: Hi, Why would this: print(request.headers) print(request.headers.get('Accept', 'No Accept')) print(request.headers.get('X-Real-Ip', 'No X-Real-Ip')) cause this output: Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8 Connection: keep-alive X-Real-Ip: 172.17.0.1 [...] text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8 No X-Real-Ip ? Notice how X-Real-Ip and its value are printed when request.headers is printed, yet the value of X-Real-Ip cannot be fetched from requests.headers. Thanks, -Tom From thomas.david.vaughan at gmail.com Thu Jul 27 11:53:40 2017 From: thomas.david.vaughan at gmail.com (Tom Vaughan) Date: Thu, 27 Jul 2017 11:53:40 -0400 Subject: [Flask] Cannot get custom header value from request.headers In-Reply-To: References: Message-ID: On Thu, Jul 27, 2017 at 12:51 AM, Tom Vaughan wrote: > Hi, > > Why would this: > > print(request.headers) > print(request.headers.get('Accept', 'No Accept')) > print(request.headers.get('X-Real-Ip', 'No X-Real-Ip')) > > cause this output: > > Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8 > Connection: keep-alive > X-Real-Ip: 172.17.0.1 > [...] > > text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8 > No X-Real-Ip > > ? So the problem is: File "/usr/local/lib/python3.5/dist-packages/werkzeug/datastructures.py", line 1349, in __getitem__ key = key.upper().replace('-', '_') if key in ('CONTENT_TYPE', 'CONTENT_LENGTH'): return _unicodify_header_value(self.environ[key]) return _unicodify_header_value(self.environ['HTTP_' + key]) The problem is that the custom header values (those that start with X-) are not capitalized in self.environ, everything else is. For example in self.environ, Accept exists as HTTP_ACCEPT, but X-Real-Ip exists as HTTP_X_Real_IP. But why? From scott.werner.vt at gmail.com Thu Jul 27 15:14:43 2017 From: scott.werner.vt at gmail.com (Scott Werner) Date: Thu, 27 Jul 2017 15:14:43 -0400 Subject: [Flask] Cannot get custom header value from request.headers In-Reply-To: References: Message-ID: Tom, Request headers key names are case-insensitive, so X-Real-Ip and X-REAL-IP would both work. I could not repeat your issue using Python 3.6: from flask import Flask, jsonify, request app = Flask(__name__) @app.route('/') def hello_world(): print(request.headers) print(request.headers.get('Accept', 'No Accept')) print(request.headers.get('X-Real-Ip', 'No X-Real-Ip')) print(request.headers.get('X-REAL-IP', 'No X-Real-Ip')) return jsonify(dict(request.headers)) app.run() $ curl --header "X-Real-Ip: 8.8.8.8" http://127.0.0.1:5000/ { "Accept": "*/*", "Host": "127.0.0.1:5000", "User-Agent": "curl/7.54.1", "X-Real-Ip": "8.8.8.8" } 127.0.0.1 - - [27/Jul/2017 15:12:18] "GET / HTTP/1.1" 200 - Host: 127.0.0.1:5000 User-Agent: curl/7.54.1 Accept: */* X-Real-Ip: 8.8.8.8 */* 8.8.8.8 8.8.8.8 On Thu, Jul 27, 2017 at 11:53 AM, Tom Vaughan < thomas.david.vaughan at gmail.com> wrote: > On Thu, Jul 27, 2017 at 12:51 AM, Tom Vaughan > wrote: > > Hi, > > > > Why would this: > > > > print(request.headers) > > print(request.headers.get('Accept', 'No Accept')) > > print(request.headers.get('X-Real-Ip', 'No X-Real-Ip')) > > > > cause this output: > > > > Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*; > q=0.8 > > Connection: keep-alive > > X-Real-Ip: 172.17.0.1 > > [...] > > > > text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8 > > No X-Real-Ip > > > > ? > > So the problem is: > > File "/usr/local/lib/python3.5/dist-packages/werkzeug/ > datastructures.py", > line 1349, in __getitem__ > > key = key.upper().replace('-', '_') > if key in ('CONTENT_TYPE', 'CONTENT_LENGTH'): > return _unicodify_header_value(self.environ[key]) > return _unicodify_header_value(self.environ['HTTP_' + key]) > > The problem is that the custom header values (those that start with > X-) are not capitalized in self.environ, everything else is. For > example in self.environ, Accept exists as HTTP_ACCEPT, but X-Real-Ip > exists as HTTP_X_Real_IP. But why? > _______________________________________________ > Flask mailing list > Flask at python.org > https://mail.python.org/mailman/listinfo/flask > -- Scott Werner scott.werner.vt at gmail.com -------------- next part -------------- An HTML attachment was scrubbed... URL: From thomas.david.vaughan at gmail.com Thu Jul 27 15:54:17 2017 From: thomas.david.vaughan at gmail.com (Tom Vaughan) Date: Thu, 27 Jul 2017 15:54:17 -0400 Subject: [Flask] Cannot get custom header value from request.headers In-Reply-To: References: Message-ID: Thanks Scott! I really appreciate that you've taken some time to look into this! The problem seems to be with nginx/uwsgi/werkzeug. This is my current work around: https://gitlab.com/tvaughan/docker-nginx-proxy-uwsgi/commit/646a22f279e665a3114baa581b3ba2c7ebfc1ad1. This simply sends the custom headers in the format expected by werkzeug when it looks up the keys in self.environment. This issue https://github.com/pallets/werkzeug/issues/940 appears to be related. My problem isn't with the same header being provided more than once, but rather this issue does say there is some condition which causes werkzeug to not coerce header names. I still don't know what that condition is. Note that in my workaround Host is OK as-is. Perhaps the condition is simply the X- prefix? Still diggin'... Thanks, -Tom On Thu, Jul 27, 2017 at 3:14 PM, Scott Werner wrote: > Tom, > > Request headers key names are case-insensitive, so X-Real-Ip and X-REAL-IP > would both work. I could not repeat your issue using Python 3.6: > > from flask import Flask, jsonify, request > > app = Flask(__name__) > > @app.route('/') > def hello_world(): > print(request.headers) > print(request.headers.get('Accept', 'No Accept')) > print(request.headers.get('X-Real-Ip', 'No X-Real-Ip')) > print(request.headers.get('X-REAL-IP', 'No X-Real-Ip')) > return jsonify(dict(request.headers)) > > app.run() > > > $ curl --header "X-Real-Ip: 8.8.8.8" http://127.0.0.1:5000/ > { > "Accept": "*/*", > "Host": "127.0.0.1:5000", > "User-Agent": "curl/7.54.1", > "X-Real-Ip": "8.8.8.8" > } > > > 127.0.0.1 - - [27/Jul/2017 15:12:18] "GET / HTTP/1.1" 200 - > Host: 127.0.0.1:5000 > User-Agent: curl/7.54.1 > Accept: */* > X-Real-Ip: 8.8.8.8 > > > */* > 8.8.8.8 > 8.8.8.8 > > > > On Thu, Jul 27, 2017 at 11:53 AM, Tom Vaughan > wrote: >> >> On Thu, Jul 27, 2017 at 12:51 AM, Tom Vaughan >> wrote: >> > Hi, >> > >> > Why would this: >> > >> > print(request.headers) >> > print(request.headers.get('Accept', 'No Accept')) >> > print(request.headers.get('X-Real-Ip', 'No X-Real-Ip')) >> > >> > cause this output: >> > >> > Accept: >> > text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8 >> > Connection: keep-alive >> > X-Real-Ip: 172.17.0.1 >> > [...] >> > >> > text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8 >> > No X-Real-Ip >> > >> > ? >> >> So the problem is: >> >> File >> "/usr/local/lib/python3.5/dist-packages/werkzeug/datastructures.py", >> line 1349, in __getitem__ >> >> key = key.upper().replace('-', '_') >> if key in ('CONTENT_TYPE', 'CONTENT_LENGTH'): >> return _unicodify_header_value(self.environ[key]) >> return _unicodify_header_value(self.environ['HTTP_' + key]) >> >> The problem is that the custom header values (those that start with >> X-) are not capitalized in self.environ, everything else is. For >> example in self.environ, Accept exists as HTTP_ACCEPT, but X-Real-Ip >> exists as HTTP_X_Real_IP. But why? >> _______________________________________________ >> Flask mailing list >> Flask at python.org >> https://mail.python.org/mailman/listinfo/flask > > > > > -- > Scott Werner > scott.werner.vt at gmail.com