From klawlor419 at gmail.com Thu Oct 1 00:54:44 2015 From: klawlor419 at gmail.com (Kyle Lawlor) Date: Wed, 30 Sep 2015 18:54:44 -0400 Subject: [Flask] (no subject) In-Reply-To: References: Message-ID: I wasn't going to permanently store them there. Just wanted to quickly test out the Stripe functionality in my site. This simple stripe flask app ( https://stripe.com/docs/checkout/guides/flask) works just fine for me stand alone. When I try to implement a similar thing in my site, I am getting the 400 errors.. if 'a' not in b seems a bit easier to read to me. Thanks! On Wed, Sep 30, 2015 at 3:57 PM, Dorian Hoxha wrote: > From a quick look, don't store config values in the code. > Careful with stripe keys (they look like test keys though) > > I think it's more pythonic: > if 'a' not in b > > instead of : > > if not 'a' in b: > > I'm not sure though. > > On Wed, Sep 30, 2015 at 9:28 PM, Kyle Lawlor wrote: > >> Ok, I will look into this first. Thanks again for the pointers. In the >> meantime, any further comments still appreciated. >> >> On Wed, Sep 30, 2015 at 2:34 PM, Dorian Hoxha >> wrote: >> >>> Replace the code like I said and try again if the error persist. >>> I don't know if the fields do(nt) exist in your code, that's why you >>> have to fix them by actually checking. >>> >>> On Wed, Sep 30, 2015 at 8:01 PM, Kyle Lawlor >>> wrote: >>> >>>> Ok. Thanks for the response. I will keep this in mind as I continue to >>>> diagnose my problem. Did you spot a place in my code where the field d.n.e.? >>>> >>>> On Wed, Sep 30, 2015 at 9:35 AM, Dorian Hoxha >>>> wrote: >>>> >>>>> ALWAYS check if the field exist in request.form, if it doesn't you >>>>> will get a 400 request-error. >>>>> 2 ways to check: >>>>> if 'field' in request.form >>>>> if request.form.get('field') >>>>> >>>>> On Wed, Sep 30, 2015 at 12:29 AM, Kyle Lawlor >>>>> wrote: >>>>> >>>>>> Hello, everyone. >>>>>> >>>>>> I've been working on web app for a friends restaurant. I am slowly >>>>>> adding the functionality that I need. Earlier today I was able to add a >>>>>> payment method via the Stripe API. I have confirmed that the test payments >>>>>> are going through to my Stripe logs. I followed very closely to the [stripe >>>>>> flask tutorial](https://stripe.com/docs/checkout/guides/flask). >>>>>> Basically I am doing the exact same thing as what is done in the tutorial, >>>>>> except I have adjusted the payment amount based on interaction with the >>>>>> "order online" portion of the website. >>>>>> >>>>>> >>>>>> *First issue:* >>>>>> >>>>>> One issue I am having (which I am sure is just a stupid mistake) is >>>>>> that once the purchase is confirmed, I redirect to a confirmation page to >>>>>> show a summary of the order, but I am getting a "400 Bad Request - CSRF >>>>>> token missing or incorrect" error. >>>>>> >>>>>> I tried to solve the problem using the methods from [this page]( >>>>>> http://flask-wtf.readthedocs.org/en/latest/csrf.html), like adding >>>>>> an empty form with a CSRF token, to no avail. I also tried including a meta >>>>>> tag with the token which also did not work. >>>>>> >>>>>> I am puzzled. A curious thing is that I can access the "payment" page >>>>>> manually via url before and after the transaction goes through. It seems >>>>>> that the trouble only happens when I redirect from the Stripe payment. >>>>>> >>>>>> *Second issue:* >>>>>> >>>>>> Another possibly related issue is that there is a segment of code >>>>>> using the stripe API I have commented out for the following reason. When it >>>>>> is uncommented I get the following error in addition to the CSRF error >>>>>> stated above, "400 Bad Request - The browser (or proxy) sent a request that >>>>>> this server could not understand." >>>>>> >>>>>> If anyone has a chance to take a look at this for me it would be >>>>>> greatly appreciated. Here is the latest version of the project (currently >>>>>> using the meta tag with CSRF). >>>>>> >>>>>> *Project:* https://github.com/callmeskywalker/casa-site >>>>>> >>>>>> >>>>>> >>>>>> *First issue relevant:* >>>>>> stripe import and test keys: >>>>>> >>>>>> https://github.com/callmeskywalker/casa-site/blob/master/app/main/views.py#L38-L43 >>>>>> >>>>>> order view function: >>>>>> >>>>>> https://github.com/callmeskywalker/casa-site/blob/master/app/main/views.py#L47-L128 >>>>>> >>>>>> >>>>>> pass stripe key to 'order' template: >>>>>> >>>>>> https://github.com/callmeskywalker/casa-site/blob/master/app/main/views.py#L128 >>>>>> >>>>>> stripe implementation in 'order' template: >>>>>> >>>>>> https://github.com/callmeskywalker/casa-site/blob/master/app/templates/order.html#L50-L64 >>>>>> >>>>>> action to redirect to the 'payment' template (just to display order >>>>>> details): >>>>>> >>>>>> https://github.com/callmeskywalker/casa-site/blob/master/app/templates/order.html#L51 >>>>>> >>>>>> payment template with csrf token: >>>>>> >>>>>> https://github.com/callmeskywalker/casa-site/blob/master/app/templates/payment.html#L5 >>>>>> >>>>>> *Second issue relevant:* >>>>>> >>>>>> code from stripe API in payment view function (causing second error): >>>>>> >>>>>> https://github.com/callmeskywalker/casa-site/blob/master/app/main/views.py#L138-L148 >>>>>> >>>>>> >>>>>> Thanks ahead. I look forward to any responses. >>>>>> >>>>>> Best, >>>>>> Kyle >>>>>> >>>>>> >>>>>> _______________________________________________ >>>>>> Flask mailing list >>>>>> Flask at python.org >>>>>> https://mail.python.org/mailman/listinfo/flask >>>>>> >>>>>> >>>>> >>>> >>> >> > -------------- next part -------------- An HTML attachment was scrubbed... URL: From smcg4191 at mtneva.com Thu Oct 1 07:15:44 2015 From: smcg4191 at mtneva.com (S McGraw) Date: Wed, 30 Sep 2015 23:15:44 -0600 Subject: [Flask] Jinja environment finalize function Message-ID: <560CC180.5060905@mtneva.com> Jinja allows one to initialize an environment with a "finalize" callable, which I want to do to convert None's to empty strings before they are output. This is much cleaner than than filling my templates with innumerable "if none ..." constructs. But I don't see in the Flask docs how to do this. Suggestions? From projetmbc at gmail.com Thu Oct 1 21:01:49 2015 From: projetmbc at gmail.com (Christophe Bal) Date: Thu, 1 Oct 2015 21:01:49 +0200 Subject: [Flask] (no subject) In-Reply-To: References: Message-ID: Yes ... not in ... Is more pythonic. Le 30 sept. 2015 21:57, "Dorian Hoxha" a ?crit : > From a quick look, don't store config values in the code. > Careful with stripe keys (they look like test keys though) > > I think it's more pythonic: > if 'a' not in b > > instead of : > > if not 'a' in b: > > I'm not sure though. > > On Wed, Sep 30, 2015 at 9:28 PM, Kyle Lawlor wrote: > >> Ok, I will look into this first. Thanks again for the pointers. In the >> meantime, any further comments still appreciated. >> >> On Wed, Sep 30, 2015 at 2:34 PM, Dorian Hoxha >> wrote: >> >>> Replace the code like I said and try again if the error persist. >>> I don't know if the fields do(nt) exist in your code, that's why you >>> have to fix them by actually checking. >>> >>> On Wed, Sep 30, 2015 at 8:01 PM, Kyle Lawlor >>> wrote: >>> >>>> Ok. Thanks for the response. I will keep this in mind as I continue to >>>> diagnose my problem. Did you spot a place in my code where the field d.n.e.? >>>> >>>> On Wed, Sep 30, 2015 at 9:35 AM, Dorian Hoxha >>>> wrote: >>>> >>>>> ALWAYS check if the field exist in request.form, if it doesn't you >>>>> will get a 400 request-error. >>>>> 2 ways to check: >>>>> if 'field' in request.form >>>>> if request.form.get('field') >>>>> >>>>> On Wed, Sep 30, 2015 at 12:29 AM, Kyle Lawlor >>>>> wrote: >>>>> >>>>>> Hello, everyone. >>>>>> >>>>>> I've been working on web app for a friends restaurant. I am slowly >>>>>> adding the functionality that I need. Earlier today I was able to add a >>>>>> payment method via the Stripe API. I have confirmed that the test payments >>>>>> are going through to my Stripe logs. I followed very closely to the [stripe >>>>>> flask tutorial](https://stripe.com/docs/checkout/guides/flask). >>>>>> Basically I am doing the exact same thing as what is done in the tutorial, >>>>>> except I have adjusted the payment amount based on interaction with the >>>>>> "order online" portion of the website. >>>>>> >>>>>> >>>>>> *First issue:* >>>>>> >>>>>> One issue I am having (which I am sure is just a stupid mistake) is >>>>>> that once the purchase is confirmed, I redirect to a confirmation page to >>>>>> show a summary of the order, but I am getting a "400 Bad Request - CSRF >>>>>> token missing or incorrect" error. >>>>>> >>>>>> I tried to solve the problem using the methods from [this page]( >>>>>> http://flask-wtf.readthedocs.org/en/latest/csrf.html), like adding >>>>>> an empty form with a CSRF token, to no avail. I also tried including a meta >>>>>> tag with the token which also did not work. >>>>>> >>>>>> I am puzzled. A curious thing is that I can access the "payment" page >>>>>> manually via url before and after the transaction goes through. It seems >>>>>> that the trouble only happens when I redirect from the Stripe payment. >>>>>> >>>>>> *Second issue:* >>>>>> >>>>>> Another possibly related issue is that there is a segment of code >>>>>> using the stripe API I have commented out for the following reason. When it >>>>>> is uncommented I get the following error in addition to the CSRF error >>>>>> stated above, "400 Bad Request - The browser (or proxy) sent a request that >>>>>> this server could not understand." >>>>>> >>>>>> If anyone has a chance to take a look at this for me it would be >>>>>> greatly appreciated. Here is the latest version of the project (currently >>>>>> using the meta tag with CSRF). >>>>>> >>>>>> *Project:* https://github.com/callmeskywalker/casa-site >>>>>> >>>>>> >>>>>> >>>>>> *First issue relevant:* >>>>>> stripe import and test keys: >>>>>> >>>>>> https://github.com/callmeskywalker/casa-site/blob/master/app/main/views.py#L38-L43 >>>>>> >>>>>> order view function: >>>>>> >>>>>> https://github.com/callmeskywalker/casa-site/blob/master/app/main/views.py#L47-L128 >>>>>> >>>>>> >>>>>> pass stripe key to 'order' template: >>>>>> >>>>>> https://github.com/callmeskywalker/casa-site/blob/master/app/main/views.py#L128 >>>>>> >>>>>> stripe implementation in 'order' template: >>>>>> >>>>>> https://github.com/callmeskywalker/casa-site/blob/master/app/templates/order.html#L50-L64 >>>>>> >>>>>> action to redirect to the 'payment' template (just to display order >>>>>> details): >>>>>> >>>>>> https://github.com/callmeskywalker/casa-site/blob/master/app/templates/order.html#L51 >>>>>> >>>>>> payment template with csrf token: >>>>>> >>>>>> https://github.com/callmeskywalker/casa-site/blob/master/app/templates/payment.html#L5 >>>>>> >>>>>> *Second issue relevant:* >>>>>> >>>>>> code from stripe API in payment view function (causing second error): >>>>>> >>>>>> https://github.com/callmeskywalker/casa-site/blob/master/app/main/views.py#L138-L148 >>>>>> >>>>>> >>>>>> Thanks ahead. I look forward to any responses. >>>>>> >>>>>> Best, >>>>>> Kyle >>>>>> >>>>>> >>>>>> _______________________________________________ >>>>>> 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 davidnieder at gmx.de Fri Oct 2 13:16:05 2015 From: davidnieder at gmx.de (David Nieder) Date: Fri, 2 Oct 2015 13:16:05 +0200 Subject: [Flask] Jinja environment finalize function In-Reply-To: <560CC180.5060905@mtneva.com> References: <560CC180.5060905@mtneva.com> Message-ID: <560E6775.5010300@gmx.de> On 01.10.2015 07:15, S McGraw wrote: > Jinja allows one to initialize an environment with a > "finalize" callable, which I want to do to convert None's > to empty strings before they are output. This is much > cleaner than than filling my templates with innumerable > "if none ..." constructs. > > But I don't see in the Flask docs how to do this. > Suggestions? Dont't know if this is the way to go but just patching the jinja environment works for me: def finalize(arg): if arg is None: return '' return arg app = Flask(__name__) app.jinja_env.finalize = finalize From malphas at subdimension.co.uk Fri Oct 2 15:33:58 2015 From: malphas at subdimension.co.uk (Malphas Wats) Date: Fri, 2 Oct 2015 14:33:58 +0100 Subject: [Flask] Why is sending a file so slow? Message-ID: Hi, I have an application that allows users to upload files. I agonized over where to actually store these files, but in the end, since I wanted to keep some form of file history, and make things easy on myself for backups and things, I went with keeping everything in the Database. I have a route that looks something like this (alright, exactly like this): mod.route('/resource//', methods=['GET']) def download_resource(resource_id, filename): ### HACK ALERT! WHOOP WHOOP WHOOP ### if 'If-Modified-Since' in request.headers: return Response(status=304) resource = model.lesson.get_lesson_resource(resource_id) if resource: r = Response(resource['file_data'], mimetype=resource['mime_type']) r.headers.add('Last-Modified', resource['timestamp'].strftime("%a, %d %b %Y %H:%M:%S GMT")) return r else: abort(404) it's a little bit hacky, but overall it does what I want. model.get_lesson_resource(resource_id) returns the blob from the database, I then build a Response object from that and return it. It is however REALLY REALLY slow at downloading the file - I can put a big file in the application's 'static' directory and Flask can send it down at my full network bandwith. If I attempt to download a large file from the route above it slows to < 2k/s. I don't understand why it's slow - it's not the database, because the blob has been pulled out from there before the Response can be returned. I've clearly done something heinous here but I can't see what it is - is there a better way to send the file back to the client? Thanks very much -Mike -------------- next part -------------- An HTML attachment was scrubbed... URL: From smcg4191 at mtneva.com Tue Oct 6 05:40:56 2015 From: smcg4191 at mtneva.com (S McGraw) Date: Mon, 5 Oct 2015 21:40:56 -0600 Subject: [Flask] Jinja environment finalize function In-Reply-To: <560E6775.5010300@gmx.de> References: <560CC180.5060905@mtneva.com> <560E6775.5010300@gmx.de> Message-ID: <561342C8.8080503@mtneva.com> On 10/02/2015 05:16 AM, David Nieder wrote: > On 01.10.2015 07:15, S McGraw wrote: >> Jinja allows one to initialize an environment with a >> "finalize" callable, which I want to do to convert None's >> to empty strings before they are output. This is much >> cleaner than than filling my templates with innumerable >> "if none ..." constructs. >> >> But I don't see in the Flask docs how to do this. >> Suggestions? > > Dont't know if this is the way to go but just patching the jinja > environment works for me: > > def finalize(arg): > if arg is None: > return '' > return arg > > app = Flask(__name__) > app.jinja_env.finalize = finalize Yup, that worked fine. I should have tried that before posting but I thought I remembered trying to do that (set the finalize value after the environment was initialized) a while ago in a non-Flask project, unsuccessfully. Or maybe Flask has not set the environment yet, I didn't look at the Flask code. In any event, thanks! From tigernassau at gmail.com Tue Oct 6 18:03:46 2015 From: tigernassau at gmail.com (tigernassau) Date: Tue, 6 Oct 2015 10:03:46 -0600 Subject: [Flask] flask uwsgi nginx deployment not working Message-ID: <5613F0E2.6020100@gmail.com> we can only get Flask to load on a debian server with nginx, uwsgi with a command line statement, not on server boot - yet we can get bottle to load just fine. most of the docs are either outdated, 80% complete, or different combinations (ie gunicorn, mod_wsgi, uwsgi-plugin-python, systemd ...) so we hope to write up a detailed set of docs that work for this combination Here's what we have: nginx.conf ..... upstream testapp { server localhost: 8082; } ..... location / { try_files $uri @wsgi; } location @wsgi { include /etc/nginx/uwsgi_params; uwsgi_pass testapp } ..... /etc/uwsgi/apps-enabled/testapp.ini [uwsgi] socket = localhost: 8082 chdir = /home/testapp file = app.py master = true plugins = python uid = www-data gid = www-data vacuum = true --- test command line run --- (works!) sudo uwsgi --socket 127.0.0.1:8082 --wsgi-file /home/testapp/app.py --callable app processes 4 --stats 127.0.0.1:9191 /etc/systemd/system/testapp.service [Unit] Description=wsgi flask testapp [Service] ExecStart=uwsgi --socket 127.0.0.1:8082 --wsgi-file /home/testapp/app.py --callable app --processes 4 Restart=always KillSignal=SIGQUIT Type=notify StandardError=syslog NotifyAccess=all [Install] WantedBy=multi-user.target sudo service testapp start ==> error The only difference we see between Flask not booting and Bottle working is in the app run statement Flask: if __name__ == '__main__': app.run() Bottle: if __name__ == '__main__': bottle.run(host="127.0.0.1",port=8082) else: app = application = bottle.default_app() maybe app run issue ?? maybe permission issue ?? (but wsgi ini works for bottle) maybe systemd service file ?? thks. -- Tiger Nassau, Inc. www.tigernassau.com From jeff at jeffwidman.com Tue Oct 6 23:03:55 2015 From: jeff at jeffwidman.com (Jeff Widman) Date: Tue, 6 Oct 2015 14:03:55 -0700 Subject: [Flask] flask uwsgi nginx deployment not working In-Reply-To: <5613F0E2.6020100@gmail.com> References: <5613F0E2.6020100@gmail.com> Message-ID: I just setup Nginx + uWSGI + Flask the other day for the first time. You're right, the Flask docs on uWSGI are outdated and use deprecated uWSGI commands. There's a pull request in the Flask repo that shows the correct way (as best I could tell) to set things up, it also covers the slightly more complicated scenario of serving multiple Flask apps on a single uWSGI socket. I take a cursory look through your code and nothing stuck out to me... I used the Emperor option in place of the Master process option, as it gives more flexibility, so maybe that's why I'm not seeing the specific issue... maybe try that? ? On Tue, Oct 6, 2015 at 9:03 AM, tigernassau wrote: > we can only get Flask to load on a debian server with nginx, uwsgi with a > command line statement, not on server boot - yet we can get bottle to load > just fine. > > most of the docs are either outdated, 80% complete, or different > combinations (ie gunicorn, mod_wsgi, uwsgi-plugin-python, systemd ...) so > we hope to write up a detailed set of docs that work for this combination > > Here's what we have: > nginx.conf > ..... > upstream testapp { > server localhost: 8082; > } > ..... > location / { > try_files $uri @wsgi; > } > location @wsgi { > include /etc/nginx/uwsgi_params; > uwsgi_pass testapp > } > ..... > > /etc/uwsgi/apps-enabled/testapp.ini > [uwsgi] > socket = localhost: 8082 > chdir = /home/testapp > file = app.py > master = true > plugins = python > uid = www-data > gid = www-data > vacuum = true > > --- test command line run --- (works!) > sudo uwsgi --socket 127.0.0.1:8082 --wsgi-file /home/testapp/app.py > --callable app processes 4 --stats 127.0.0.1:9191 > > /etc/systemd/system/testapp.service > [Unit] > Description=wsgi flask testapp > [Service] > ExecStart=uwsgi --socket 127.0.0.1:8082 --wsgi-file /home/testapp/app.py > --callable app --processes 4 > Restart=always > KillSignal=SIGQUIT > Type=notify > StandardError=syslog > NotifyAccess=all > > [Install] > WantedBy=multi-user.target > > sudo service testapp start ==> error > > The only difference we see between Flask not booting and Bottle working is > in the app run statement > Flask: > if __name__ == '__main__': > app.run() > > Bottle: > if __name__ == '__main__': > bottle.run(host="127.0.0.1",port=8082) > else: > app = application = bottle.default_app() > > > maybe app run issue ?? > maybe permission issue ?? (but wsgi ini works for bottle) > maybe systemd service file ?? > > thks. > > -- > Tiger Nassau, Inc. > www.tigernassau.com > > _______________________________________________ > Flask mailing list > Flask at python.org > https://mail.python.org/mailman/listinfo/flask > -- *Jeff Widman* jeffwidman.com | 740-WIDMAN-J (943-6265) <>< -------------- next part -------------- An HTML attachment was scrubbed... URL: From tigernassau at gmail.com Wed Oct 7 01:03:54 2015 From: tigernassau at gmail.com (tigernassau) Date: Tue, 6 Oct 2015 17:03:54 -0600 Subject: [Flask] flask uwsgi nginx deployment not working In-Reply-To: References: <5613F0E2.6020100@gmail.com> Message-ID: <5614535A.8080406@gmail.com> Hmm, looked at pull request - more confusion! Would try emperor but see no docs on that - is your setup something you can post?. Otherwise we have Bottle working nicely (and only seems to be missing session vs Flask, so it might be easier to just get Beaker working with Bottle On 10/06/2015 03:03 PM, Jeff Widman wrote: > I just setup Nginx + uWSGI + Flask the other day for the first time. > You're right, the Flask docs on uWSGI are outdated and use deprecated > uWSGI commands. There's a pull request in the Flask repo that shows > the correct way (as best I could tell) to set things up, it also > covers the slightly more complicated scenario of serving multiple > Flask apps on a single uWSGI socket. > > I take a cursory look through your code and nothing stuck out to me... > I used the Emperor option in place of the Master process option, as it > gives more flexibility, so maybe that's why I'm not seeing the > specific issue... maybe try that? > ? > > On Tue, Oct 6, 2015 at 9:03 AM, tigernassau > wrote: > > we can only get Flask to load on a debian server with nginx, uwsgi > with a command line statement, not on server boot - yet we can get > bottle to load just fine. > > most of the docs are either outdated, 80% complete, or different > combinations (ie gunicorn, mod_wsgi, uwsgi-plugin-python, systemd > ...) so we hope to write up a detailed set of docs that work for > this combination > > Here's what we have: > nginx.conf > ..... > upstream testapp { > server localhost: 8082; > } > ..... > location / { > try_files $uri @wsgi; > } > location @wsgi { > include /etc/nginx/uwsgi_params; > uwsgi_pass testapp > } > ..... > > /etc/uwsgi/apps-enabled/testapp.ini > [uwsgi] > socket = localhost: 8082 > chdir = /home/testapp > file = app.py > master = true > plugins = python > uid = www-data > gid = www-data > vacuum = true > > --- test command line run --- (works!) > sudo uwsgi --socket 127.0.0.1:8082 > --wsgi-file /home/testapp/app.py --callable app processes 4 > --stats 127.0.0.1:9191 > > /etc/systemd/system/testapp.service > [Unit] > Description=wsgi flask testapp > [Service] > ExecStart=uwsgi --socket 127.0.0.1:8082 > --wsgi-file /home/testapp/app.py --callable app --processes 4 > Restart=always > KillSignal=SIGQUIT > Type=notify > StandardError=syslog > NotifyAccess=all > > [Install] > WantedBy=multi-user.target > > sudo service testapp start ==> error > > The only difference we see between Flask not booting and Bottle > working is in the app run statement > Flask: > if __name__ == '__main__': > app.run() > > Bottle: > if __name__ == '__main__': > bottle.run(host="127.0.0.1",port=8082) > else: > app = application = bottle.default_app() > > > maybe app run issue ?? > maybe permission issue ?? (but wsgi ini works for bottle) > maybe systemd service file ?? > > thks. > > -- > Tiger Nassau, Inc. > www.tigernassau.com > > _______________________________________________ > Flask mailing list > Flask at python.org > https://mail.python.org/mailman/listinfo/flask > > > > > -- > * > Jeff Widman* > jeffwidman.com | 740-WIDMAN-J (943-6265) > <>< > > > _______________________________________________ > Flask mailing list > Flask at python.org > https://mail.python.org/mailman/listinfo/flask -- Tiger Nassau, Inc. www.tigernassau.com -------------- next part -------------- An HTML attachment was scrubbed... URL: From canhosgor at gmail.com Wed Oct 7 09:09:31 2015 From: canhosgor at gmail.com (=?UTF-8?B?Q2FuIEhvxZ9nw7Zy?=) Date: Wed, 7 Oct 2015 10:09:31 +0300 Subject: [Flask] Why is sending a file so slow? In-Reply-To: References: Message-ID: If you are sure the problem is not the db. I would try the following: Streaming responses: http://flask.pocoo.org/docs/0.10/patterns/streaming/ send_file: http://flask.pocoo.org/snippets/32/ But IMHO, the downsides of storing large files in the DB will outweigh its benefits in the long run. You can store contents somewhere on the filesystem and just store the file path in the db. You don't need to sacrifice history this way, just make sure you put contents to new files instead of overwriting old ones. (You can use file hash to generate unique filenames) On Fri, Oct 2, 2015 at 4:33 PM, Malphas Wats wrote: > Hi, > > I have an application that allows users to upload files. I agonized over > where to actually store these files, but in the end, since I wanted to keep > some form of file history, and make things easy on myself for backups and > things, I went with keeping everything in the Database. > > I have a route that looks something like this (alright, exactly like this): > > mod.route('/resource//', methods=['GET']) > def download_resource(resource_id, filename): > ### HACK ALERT! WHOOP WHOOP WHOOP ### > if 'If-Modified-Since' in request.headers: > return Response(status=304) > resource = model.lesson.get_lesson_resource(resource_id) > > if resource: > r = Response(resource['file_data'], mimetype=resource['mime_type']) > r.headers.add('Last-Modified', resource['timestamp'].strftime("%a, > %d %b %Y %H:%M:%S GMT")) > return r > else: > abort(404) > > it's a little bit hacky, but overall it does what I want. > model.get_lesson_resource(resource_id) returns the blob from the database, I > then build a Response object from that and return it. > > It is however REALLY REALLY slow at downloading the file - I can put a big > file in the application's 'static' directory and Flask can send it down at > my full network bandwith. > > If I attempt to download a large file from the route above it slows to < > 2k/s. > > I don't understand why it's slow - it's not the database, because the blob > has been pulled out from there before the Response can be returned. I've > clearly done something heinous here but I can't see what it is - is there a > better way to send the file back to the client? > > Thanks very much > -Mike > > _______________________________________________ > Flask mailing list > Flask at python.org > https://mail.python.org/mailman/listinfo/flask > From jicenhower at yahoo.com Thu Oct 8 16:41:22 2015 From: jicenhower at yahoo.com (Jim Icenhower) Date: Thu, 8 Oct 2015 14:41:22 +0000 (UTC) Subject: [Flask] How to downgrade flask-login to earlier version? References: <1543331028.867117.1444315282975.JavaMail.yahoo@mail.yahoo.com> Message-ID: <1543331028.867117.1444315282975.JavaMail.yahoo@mail.yahoo.com> Hi,I'm using Pycharm as my IDE. The current version of flask-login (0.3.1) that I have installed is not compatible with the apps I've built in flask-appbuilder so I need to downgrade back to version 0.2.11. Pycharm doesn't list any earlier versions of flask-login in it's package manager so I think I have to use pip or easy-install but I don't know how to specify a version. Can anyone tell me how or point me to some help? Thanks!?Jim -------------- next part -------------- An HTML attachment was scrubbed... URL: From dorian.hoxha at gmail.com Thu Oct 8 16:46:57 2015 From: dorian.hoxha at gmail.com (Dorian Hoxha) Date: Thu, 8 Oct 2015 16:46:57 +0200 Subject: [Flask] How to downgrade flask-login to earlier version? In-Reply-To: <1543331028.867117.1444315282975.JavaMail.yahoo@mail.yahoo.com> References: <1543331028.867117.1444315282975.JavaMail.yahoo@mail.yahoo.com> <1543331028.867117.1444315282975.JavaMail.yahoo@mail.yahoo.com> Message-ID: Can you search how to install specific version of package in pip ? On Thu, Oct 8, 2015 at 4:41 PM, Jim Icenhower via Flask wrote: > Hi, > I'm using Pycharm as my IDE. The current version of flask-login (0.3.1) > that I have installed is not compatible with the apps I've built in > flask-appbuilder so I need to downgrade back to version 0.2.11. Pycharm > doesn't list any earlier versions of flask-login in it's package manager so > I think I have to use pip or easy-install but I don't know how to specify a > version. Can anyone tell me how or point me to some help? > > Thanks! > > Jim > > _______________________________________________ > Flask mailing list > Flask at python.org > https://mail.python.org/mailman/listinfo/flask > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From brijeshb42 at gmail.com Thu Oct 8 19:53:59 2015 From: brijeshb42 at gmail.com (Brijesh Bittu) Date: Thu, 8 Oct 2015 23:23:59 +0530 Subject: [Flask] How to downgrade flask-login to earlier version? In-Reply-To: References: <1543331028.867117.1444315282975.JavaMail.yahoo@mail.yahoo.com> Message-ID: pip uninstall flask-login pip install flask-login==0.2.11 On Thu, Oct 8, 2015 at 8:16 PM, Dorian Hoxha wrote: > Can you search how to install specific version of package in pip ? > > On Thu, Oct 8, 2015 at 4:41 PM, Jim Icenhower via Flask > wrote: > >> Hi, >> I'm using Pycharm as my IDE. The current version of flask-login (0.3.1) >> that I have installed is not compatible with the apps I've built in >> flask-appbuilder so I need to downgrade back to version 0.2.11. Pycharm >> doesn't list any earlier versions of flask-login in it's package manager so >> I think I have to use pip or easy-install but I don't know how to specify a >> version. Can anyone tell me how or point me to some help? >> >> Thanks! >> >> Jim >> >> _______________________________________________ >> 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 jicenhower at yahoo.com Thu Oct 8 22:41:04 2015 From: jicenhower at yahoo.com (Jim Icenhower) Date: Thu, 8 Oct 2015 20:41:04 +0000 (UTC) Subject: [Flask] How to downgrade flask-login to earlier version? In-Reply-To: References: <1543331028.867117.1444315282975.JavaMail.yahoo@mail.yahoo.com> Message-ID: <1701161600.1080634.1444336864031.JavaMail.yahoo@mail.yahoo.com> That did it. Thanks!?Jim From: Brijesh Bittu To: Dorian Hoxha Cc: Jim Icenhower ; "flask at python.org" Sent: Thursday, October 8, 2015 12:53 PM Subject: Re: [Flask] How to downgrade flask-login to earlier version? pip uninstall flask-loginpip install flask-login==0.2.11 On Thu, Oct 8, 2015 at 8:16 PM, Dorian Hoxha wrote: Can you search how to install specific version of package in pip ? On Thu, Oct 8, 2015 at 4:41 PM, Jim Icenhower via Flask wrote: Hi,I'm using Pycharm as my IDE. The current version of flask-login (0.3.1) that I have installed is not compatible with the apps I've built in flask-appbuilder so I need to downgrade back to version 0.2.11. Pycharm doesn't list any earlier versions of flask-login in it's package manager so I think I have to use pip or easy-install but I don't know how to specify a version. Can anyone tell me how or point me to some help? Thanks!?Jim _______________________________________________ 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 451517996 at qq.com Sat Oct 10 17:04:50 2015 From: 451517996 at qq.com (=?gb18030?B?zuLD+g==?=) Date: Sat, 10 Oct 2015 23:04:50 +0800 Subject: [Flask] a web framework based on flask Message-ID: github: https://github.com/theDarkForce/plask a web framework based on flask by codergen?welcome everyone have a opinion to me -------------- next part -------------- An HTML attachment was scrubbed... URL: From jicenhower at yahoo.com Sat Oct 10 17:48:53 2015 From: jicenhower at yahoo.com (Jim Icenhower) Date: Sat, 10 Oct 2015 15:48:53 +0000 (UTC) Subject: [Flask] Question on iterating over records read using pyexcel References: <999520356.1907376.1444492133762.JavaMail.yahoo@mail.yahoo.com> Message-ID: <999520356.1907376.1444492133762.JavaMail.yahoo@mail.yahoo.com> I'm getting an error when iterating over the records read from a very simple xlsx file. I've tried reading a csv file and the results are the same. The code below prints the 3 records in the file then it seems like it's attempting to read another record from the records collection. What am I doing wrong? Thanks! Here's the code:import os from models import Product, ProductType, Event, CarClass, Vehicle, Registrant from flask import render_template from flask.ext.appbuilder.views import ModelView, BaseView, has_access, expose from flask.ext.appbuilder.charts.views import ChartView from flask.ext.appbuilder.models.sqla.interface import SQLAInterface from flask.ext.appbuilder.widgets import ListBlock, ShowBlockWidget import pyexcel as pe from werkzeug import secure_filenamefrom app import dbdef doEventsImport(): if request.method == 'POST': file = request.files['file'] if file and allowed_file(file.filename): filename = secure_filename(file.filename) fullName = os.path.join(app.config['UPLOAD_FOLDER'], filename) file.save(fullName) records = pe.get_records(file_name=fullName) for record in records: print record Console ouput of the 3 records:{'EventKey': u'TXABCD2014', 'Name': u'Texas All British Car Days 2014-a'}{'EventKey': u'TXABCD2015', 'Name': u'Texas All British Car Days 2015'}{'EventKey': u'TXABCD2016', 'Name': u'Texas All British Car Days 2016'} Error stack: 2015-10-10 10:43:31,993:INFO:werkzeug:127.0.0.1 - - [10/Oct/2015 10:43:31] "POST /importEvents HTTP/1.1" 500 -Traceback (most recent call last):? File "C:\Python27\lib\site-packages\flask\app.py", line 1836, in __call__? ? return self.wsgi_app(environ, start_response)? File "C:\Python27\lib\site-packages\flask\app.py", line 1820, in wsgi_app? ? response = self.make_response(self.handle_exception(e))? File "C:\Python27\lib\site-packages\flask\app.py", line 1403, in handle_exception? ? reraise(exc_type, exc_value, tb)? File "C:\Python27\lib\site-packages\flask\app.py", line 1817, in wsgi_app? ? response = self.full_dispatch_request()? File "C:\Python27\lib\site-packages\flask\app.py", line 1478, in full_dispatch_request? ? response = self.make_response(rv)? File "C:\Python27\lib\site-packages\flask\app.py", line 1566, in make_response? ? raise ValueError('View function did not return a response')ValueError: View function did not return a response?Jim -------------- next part -------------- An HTML attachment was scrubbed... URL: From tamasiaina at gmail.com Sat Oct 10 17:58:32 2015 From: tamasiaina at gmail.com (Jonathan Chen) Date: Sat, 10 Oct 2015 08:58:32 -0700 Subject: [Flask] Question on iterating over records read using pyexcel In-Reply-To: <999520356.1907376.1444492133762.JavaMail.yahoo@mail.yahoo.com> References: <999520356.1907376.1444492133762.JavaMail.yahoo@mail.yahoo.com> <999520356.1907376.1444492133762.JavaMail.yahoo@mail.yahoo.com> Message-ID: Yeah, the issue is that you are not returning anything. If you just do a return record it should not throw an error. ~Jonathan C. On Sat, Oct 10, 2015 at 8:48 AM, Jim Icenhower via Flask wrote: > I'm getting an error when iterating over the records read from a very > simple xlsx file. I've tried reading a csv file and the results are the > same. The code below prints the 3 records in the file then it seems like > it's attempting to read another record from the records collection. What am > I doing wrong? > > Thanks! > > Here's the code: > > import os > > from models import Product, ProductType, Event, CarClass, Vehicle, Registrant > from flask import render_template > from flask.ext.appbuilder.views import ModelView, BaseView, has_access, expose > from flask.ext.appbuilder.charts.views import ChartView > from flask.ext.appbuilder.models.sqla.interface import SQLAInterface > from flask.ext.appbuilder.widgets import ListBlock, ShowBlockWidget > import pyexcel as pe > from werkzeug import secure_filename > > from app import db > > def doEventsImport(): > if request.method == 'POST': > file = request.files['file'] > if file and allowed_file(file.filename): > filename = secure_filename(file.filename) > fullName = os.path.join(app.config['UPLOAD_FOLDER'], filename) > file.save(fullName) > > records = pe.get_records(file_name=fullName) > for record in records: > print record > > Console ouput of the 3 records: > {'EventKey': u'TXABCD2014', 'Name': u'Texas All British Car Days 2014-a'} > {'EventKey': u'TXABCD2015', 'Name': u'Texas All British Car Days 2015'} > {'EventKey': u'TXABCD2016', 'Name': u'Texas All British Car Days 2016'} > > Error stack: > > 2015-10-10 10:43:31,993:INFO:werkzeug:127.0.0.1 - - [10/Oct/2015 10:43:31] > "POST /importEvents HTTP/1.1" 500 - > Traceback (most recent call last): > File "C:\Python27\lib\site-packages\flask\app.py", line 1836, in __call__ > return self.wsgi_app(environ, start_response) > File "C:\Python27\lib\site-packages\flask\app.py", line 1820, in wsgi_app > response = self.make_response(self.handle_exception(e)) > File "C:\Python27\lib\site-packages\flask\app.py", line 1403, in > handle_exception > reraise(exc_type, exc_value, tb) > File "C:\Python27\lib\site-packages\flask\app.py", line 1817, in wsgi_app > response = self.full_dispatch_request() > File "C:\Python27\lib\site-packages\flask\app.py", line 1478, in > full_dispatch_request > response = self.make_response(rv) > File "C:\Python27\lib\site-packages\flask\app.py", line 1566, in > make_response > raise ValueError('View function did not return a response') > ValueError: View function did not return a response > > Jim > > _______________________________________________ > Flask mailing list > Flask at python.org > https://mail.python.org/mailman/listinfo/flask > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From dorian.hoxha at gmail.com Sat Oct 10 18:04:37 2015 From: dorian.hoxha at gmail.com (Dorian Hoxha) Date: Sat, 10 Oct 2015 18:04:37 +0200 Subject: [Flask] a web framework based on flask In-Reply-To: References: Message-ID: - No readme - no description - no pip - .pyc files in git - no comments on commits - configuration inside log.py, - dynamic pythoncode file-writing inside plaskapp.py ? - no requirements.txt - should run pep8/pylint/whatever (example class names should be UpperCase) I just don't know/see/understand what it does/how-to-use-it. On Sat, Oct 10, 2015 at 5:04 PM, ?? <451517996 at qq.com> wrote: > github: https://github.com/theDarkForce/plask > a web framework based on flask by codergen?welcome everyone have a opinion > to me > > _______________________________________________ > Flask mailing list > Flask at python.org > https://mail.python.org/mailman/listinfo/flask > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From jicenhower at yahoo.com Sat Oct 10 18:04:00 2015 From: jicenhower at yahoo.com (Jim Icenhower) Date: Sat, 10 Oct 2015 16:04:00 +0000 (UTC) Subject: [Flask] Question on iterating over records read using pyexcel In-Reply-To: References: <999520356.1907376.1444492133762.JavaMail.yahoo@mail.yahoo.com> <999520356.1907376.1444492133762.JavaMail.yahoo@mail.yahoo.com> Message-ID: <1581982772.1189671.1444493040889.JavaMail.yahoo@mail.yahoo.com> What a newbie mistake! Thanks for the help.?Jim From: Jonathan Chen To: Jim Icenhower Cc: "flask at python.org" Sent: Saturday, October 10, 2015 10:58 AM Subject: Re: [Flask] Question on iterating over records read using pyexcel Yeah, the issue is that you are not returning anything. If you just do a return record it should not throw an error.? ~Jonathan C. On Sat, Oct 10, 2015 at 8:48 AM, Jim Icenhower via Flask wrote: I'm getting an error when iterating over the records read from a very simple xlsx file. I've tried reading a csv file and the results are the same. The code below prints the 3 records in the file then it seems like it's attempting to read another record from the records collection. What am I doing wrong? Thanks! Here's the code:import os from models import Product, ProductType, Event, CarClass, Vehicle, Registrant from flask import render_template from flask.ext.appbuilder.views import ModelView, BaseView, has_access, expose from flask.ext.appbuilder.charts.views import ChartView from flask.ext.appbuilder.models.sqla.interface import SQLAInterface from flask.ext.appbuilder.widgets import ListBlock, ShowBlockWidget import pyexcel as pe from werkzeug import secure_filenamefrom app import dbdef doEventsImport(): if request.method == 'POST': file = request.files['file'] if file and allowed_file(file.filename): filename = secure_filename(file.filename) fullName = os.path.join(app.config['UPLOAD_FOLDER'], filename) file.save(fullName) records = pe.get_records(file_name=fullName) for record in records: print record Console ouput of the 3 records:{'EventKey': u'TXABCD2014', 'Name': u'Texas All British Car Days 2014-a'}{'EventKey': u'TXABCD2015', 'Name': u'Texas All British Car Days 2015'}{'EventKey': u'TXABCD2016', 'Name': u'Texas All British Car Days 2016'} Error stack: 2015-10-10 10:43:31,993:INFO:werkzeug:127.0.0.1 - - [10/Oct/2015 10:43:31] "POST /importEvents HTTP/1.1" 500 -Traceback (most recent call last):? File "C:\Python27\lib\site-packages\flask\app.py", line 1836, in __call__? ? return self.wsgi_app(environ, start_response)? File "C:\Python27\lib\site-packages\flask\app.py", line 1820, in wsgi_app? ? response = self.make_response(self.handle_exception(e))? File "C:\Python27\lib\site-packages\flask\app.py", line 1403, in handle_exception? ? reraise(exc_type, exc_value, tb)? File "C:\Python27\lib\site-packages\flask\app.py", line 1817, in wsgi_app? ? response = self.full_dispatch_request()? File "C:\Python27\lib\site-packages\flask\app.py", line 1478, in full_dispatch_request? ? response = self.make_response(rv)? File "C:\Python27\lib\site-packages\flask\app.py", line 1566, in make_response? ? raise ValueError('View function did not return a response')ValueError: View function did not return a response?Jim _______________________________________________ Flask mailing list Flask at python.org https://mail.python.org/mailman/listinfo/flask -------------- next part -------------- An HTML attachment was scrubbed... URL: From casahome2000 at gmail.com Sat Oct 10 18:29:18 2015 From: casahome2000 at gmail.com (casahome2000) Date: Sat, 10 Oct 2015 09:29:18 -0700 Subject: [Flask] a web framework based on flask In-Reply-To: References: Message-ID: <1C1758B2-2B35-4359-ADD3-731F63C190D1@gmail.com> Thanks Dorian for the huge savings of time. Sent from my iPhone > On Oct 10, 2015, at 9:04 AM, Dorian Hoxha wrote: > > No readme > no description > no pip > .pyc files in git > no comments on commits > configuration inside log.py, > dynamic pythoncode file-writing inside plaskapp.py ? > no requirements.txt > should run pep8/pylint/whatever (example class names should be UpperCase) > I just don't know/see/understand what it does/how-to-use-it. > > >> On Sat, Oct 10, 2015 at 5:04 PM, ?? <451517996 at qq.com> wrote: >> github: https://github.com/theDarkForce/plask >> a web framework based on flask by codergen?welcome everyone have a opinion to me >> >> _______________________________________________ >> 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 tamasiaina at gmail.com Sat Oct 10 19:01:18 2015 From: tamasiaina at gmail.com (Jonathan Chen) Date: Sat, 10 Oct 2015 10:01:18 -0700 Subject: [Flask] Question on iterating over records read using pyexcel In-Reply-To: <1581982772.1189671.1444493040889.JavaMail.yahoo@mail.yahoo.com> References: <999520356.1907376.1444492133762.JavaMail.yahoo@mail.yahoo.com> <1581982772.1189671.1444493040889.JavaMail.yahoo@mail.yahoo.com> Message-ID: No worries, I run into that one often by accident, so I'm use to seeing that error. ~Jonathan C. On Sat, Oct 10, 2015 at 9:04 AM, Jim Icenhower wrote: > What a newbie mistake! Thanks for the help. > > Jim > > ------------------------------ > *From:* Jonathan Chen > *To:* Jim Icenhower > *Cc:* "flask at python.org" > *Sent:* Saturday, October 10, 2015 10:58 AM > *Subject:* Re: [Flask] Question on iterating over records read using > pyexcel > > Yeah, the issue is that you are not returning anything. If you just do a > return record it should not throw an error. > > > ~Jonathan C. > > On Sat, Oct 10, 2015 at 8:48 AM, Jim Icenhower via Flask > wrote: > > > > I'm getting an error when iterating over the records read from a very > simple xlsx file. I've tried reading a csv file and the results are the > same. The code below prints the 3 records in the file then it seems like > it's attempting to read another record from the records collection. What am > I doing wrong? > > Thanks! > > Here's the code: > > import os > > from models import Product, ProductType, Event, CarClass, Vehicle, Registrant > from flask import render_template > from flask.ext.appbuilder.views import ModelView, BaseView, has_access, expose > from flask.ext.appbuilder.charts.views import ChartView > from flask.ext.appbuilder.models.sqla.interface import SQLAInterface > from flask.ext.appbuilder.widgets import ListBlock, ShowBlockWidget > import pyexcel as pe > from werkzeug import secure_filename > > from app import db > > def doEventsImport(): > if request.method == 'POST': > file = request.files['file'] > if file and allowed_file(file.filename): > filename = secure_filename(file.filename) > fullName = os.path.join(app.config['UPLOAD_FOLDER'], filename) > file.save(fullName) > > records = pe.get_records(file_name=fullName) > for record in records: > print record > > Console ouput of the 3 records: > {'EventKey': u'TXABCD2014', 'Name': u'Texas All British Car Days 2014-a'} > {'EventKey': u'TXABCD2015', 'Name': u'Texas All British Car Days 2015'} > {'EventKey': u'TXABCD2016', 'Name': u'Texas All British Car Days 2016'} > > Error stack: > > 2015-10-10 10:43:31,993:INFO:werkzeug:127.0.0.1 - - [10/Oct/2015 10:43:31] > "POST /importEvents HTTP/1.1" 500 - > Traceback (most recent call last): > File "C:\Python27\lib\site-packages\flask\app.py", line 1836, in __call__ > return self.wsgi_app(environ, start_response) > File "C:\Python27\lib\site-packages\flask\app.py", line 1820, in wsgi_app > response = self.make_response(self.handle_exception(e)) > File "C:\Python27\lib\site-packages\flask\app.py", line 1403, in > handle_exception > reraise(exc_type, exc_value, tb) > File "C:\Python27\lib\site-packages\flask\app.py", line 1817, in wsgi_app > response = self.full_dispatch_request() > File "C:\Python27\lib\site-packages\flask\app.py", line 1478, in > full_dispatch_request > response = self.make_response(rv) > File "C:\Python27\lib\site-packages\flask\app.py", line 1566, in > make_response > raise ValueError('View function did not return a response') > ValueError: View function did not return a response > > Jim > > _______________________________________________ > Flask mailing list > Flask at python.org > https://mail.python.org/mailman/listinfo/flask > > > > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From smcg4191 at mtneva.com Tue Oct 13 19:26:25 2015 From: smcg4191 at mtneva.com (S McGraw) Date: Tue, 13 Oct 2015 11:26:25 -0600 Subject: [Flask] urls when running under gunicorn Message-ID: <561D3EC1.8020300@mtneva.com> I new to flask and have a small first app working under flask's development server. In the templates I used url_for(), under the impression that would adjust the app's urls when I later run it behind a web server. I have now gotten it to run under gunicorn and set up a reverse proxy to it in my Apache (2.4) web server. It worked ok when configured as a virtual host. However, I want to run my app under a url in my regular url namespace, eg: http://myhost.com/myapp/(login,main,etc...) The trouble is that the urls in the rendered templates are still "/login", "/main", etc rather than /myapp/login, /myapp/main, etc which of course result in a 404 when clicked on. So I'm sure there is some step or piece of code I'm missing. FWIW, I tried using the werkzeug ProxyFix middleware suggested in the "Proxy Setups" section of the Flask docs, no effect. I saw recommendations to use Flask Snippets #35, along with configuring the web server to send certain headers, but they all seemed to be for Nginx, and seemed an awfully heavy-weight answer. Surely there is a simpler flask-only way to fix this? Also I read about Apache's mod_proxy_html but that too seems a little overkill to me.) I did get things to work by losing the url_for()'s in my code and templates, replaced with eg, g.prefix+'/main', where g.prefix is set to "/myapp" in a before_request() function. But I don't think that's the recommended practice. ;-) What am I missing? From smcg4191 at mtneva.com Tue Oct 13 19:50:36 2015 From: smcg4191 at mtneva.com (S McGraw) Date: Tue, 13 Oct 2015 11:50:36 -0600 Subject: [Flask] Maillist via gmane? In-Reply-To: <561342C8.8080503@mtneva.com> References: <560CC180.5060905@mtneva.com> <560E6775.5010300@gmx.de> <561342C8.8080503@mtneva.com> Message-ID: <561D446C.6060209@mtneva.com> I gather that the flask mailing list was moved a few months ago? Gmane has a "comp.web.flask.general" that seems to be the old list, judging by the fact that messages to it stopped in july. Are there any plans for Gmane to mirror the current list? (Not sure whether this is a ball in Gmane's court or the list maintainers'.) I've always found it convenient to subscribe to a list for the ability to post, but to disable message delivery and read the list via Gmane/nntp. From coreybrett at gmail.com Tue Oct 13 21:00:33 2015 From: coreybrett at gmail.com (Corey Boyle) Date: Tue, 13 Oct 2015 15:00:33 -0400 Subject: [Flask] urls when running under gunicorn In-Reply-To: <561D3EC1.8020300@mtneva.com> References: <561D3EC1.8020300@mtneva.com> Message-ID: I think what you are looking for is the "APPLICATION_ROOT" config item. http://flask.pocoo.org/docs/0.10/config/ But don't take my word for it. On Tue, Oct 13, 2015 at 1:26 PM, S McGraw wrote: > I new to flask and have a small first app working under flask's > development server. In the templates I used url_for(), under the > impression that would adjust the app's urls when I later run it > behind a web server. > > I have now gotten it to run under gunicorn and set up a reverse > proxy to it in my Apache (2.4) web server. It worked ok when > configured as a virtual host. However, I want to run my app under > a url in my regular url namespace, eg: > http://myhost.com/myapp/(login,main,etc...) > The trouble is that the urls in the rendered templates are still > "/login", "/main", etc rather than /myapp/login, /myapp/main, etc > which of course result in a 404 when clicked on. So I'm sure there > is some step or piece of code I'm missing. > > FWIW, I tried using the werkzeug ProxyFix middleware suggested in > the "Proxy Setups" section of the Flask docs, no effect. I saw > recommendations to use Flask Snippets #35, along with configuring > the web server to send certain headers, but they all seemed to be > for Nginx, and seemed an awfully heavy-weight answer. Surely there > is a simpler flask-only way to fix this? Also I read about Apache's > mod_proxy_html but that too seems a little overkill to me.) > > I did get things to work by losing the url_for()'s in my code and > templates, replaced with eg, g.prefix+'/main', where g.prefix is set > to "/myapp" in a before_request() function. But I don't think that's > the recommended practice. ;-) > > What am I missing? > _______________________________________________ > Flask mailing list > Flask at python.org > https://mail.python.org/mailman/listinfo/flask From kajocina at gmail.com Wed Oct 14 15:23:49 2015 From: kajocina at gmail.com (Piotr Grabowski) Date: Wed, 14 Oct 2015 15:23:49 +0200 Subject: [Flask] interactive forms that "talk" to one another on a page ? Message-ID: Dear Flaskers, I have a general question about a possible solution to my problem. What I would like to do is to have two forms on a page, next to one another. Now, I know how to generally make forms (I am using wtf forms), but what I need is to have one form hold entries that will be read in from a .csv file in the background in Flask. The user should scroll through those entries and be able to, upon clicking, make an entry appear in the other form. Could I get some general tips to where to look for solutions ? It would be also great to have a filter box where users could enter a phrase and only get matching results in that form with the list, so he/she doesn't have to scroll forever. I appreciate any help! Best, Piotr -------------- next part -------------- An HTML attachment was scrubbed... URL: From dorian.hoxha at gmail.com Wed Oct 14 17:27:35 2015 From: dorian.hoxha at gmail.com (Dorian Hoxha) Date: Wed, 14 Oct 2015 17:27:35 +0200 Subject: [Flask] interactive forms that "talk" to one another on a page ? In-Reply-To: References: Message-ID: You have to use javascript (assuming you want without refresh?). In the first case, I think you have a "table" not a form (the listing of the entries, i don't know how you list entries in a form?) To search without refreshing you can use something like this: https://www.datatables.net/ When the button is clicked, you run your js-code that shows the entry to the other form. On Wed, Oct 14, 2015 at 3:23 PM, Piotr Grabowski wrote: > Dear Flaskers, > > I have a general question about a possible solution to my problem. > > What I would like to do is to have two forms on a page, next to one > another. Now, I know how to generally make forms (I am using wtf forms), > but what I need is to have one form hold entries that will be read in from > a .csv file in the background in Flask. The user should scroll through > those entries and be able to, upon clicking, make an entry appear in the > other form. > > Could I get some general tips to where to look for solutions ? > > It would be also great to have a filter box where users could enter a > phrase and only get matching results in that form with the list, so he/she > doesn't have to scroll forever. > > I appreciate any help! > > > Best, > Piotr > > _______________________________________________ > Flask mailing list > Flask at python.org > https://mail.python.org/mailman/listinfo/flask > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From jicenhower at yahoo.com Wed Oct 14 19:19:46 2015 From: jicenhower at yahoo.com (Jim Icenhower) Date: Wed, 14 Oct 2015 17:19:46 +0000 (UTC) Subject: [Flask] Macro expansion/evaluation? References: <1170659701.351758.1444843186836.JavaMail.yahoo@mail.yahoo.com> Message-ID: <1170659701.351758.1444843186836.JavaMail.yahoo@mail.yahoo.com> Hi All,I'm sure this is a newbie question but I haven't been able to find the answer by searching. Probably because I don't know what this technique is called in Python.?I have created a class which extends the Flask-Appbuilder Model class which extends a SQLAlchemy class. I'm trying to validate that all required fields are populated. I have created this function that returns all the mapped attributes of the class: def get_obj_mapped_columns(dbObj): mapper = inspect(dbObj) return mapper.mapper.columns This is my main class: class Event(Model): EventID = Column(Integer, primary_key=True) EventKey = Column(String(30), unique=True, nullable=False) Name = Column(String(100), nullable=False) Description = Column(Text(1000), nullable=False) BeginDate = Column(Date) EndDate = Column(Date) RegBeginDate = Column(Date) RegEndDate = Column(Date) Location = Column(String(200)) Address1 = Column(String(200)) Address2 = Column(String(200)) City = Column(String(20)) State = Column(String(2)) Zip = Column(String(10)) URL = Column(String(100)) Email = Column(String(100)) Phone = Column(String(20))Which contains the following method:????def isValid(self): ???? columns = get_obj_mapped_columns(self) ???? for column in columns: ???? if (NOT column.nullable): ???? print column.name ???? print self. I would like to substitute the value in in such a way that it is evaluated as the field name of the Event object. Any guidance would be greatly appreciated! Thanks,Jim?Jim -------------- next part -------------- An HTML attachment was scrubbed... URL: From canhosgor at gmail.com Wed Oct 14 21:10:48 2015 From: canhosgor at gmail.com (=?UTF-8?B?Q2FuIEhvxZ9nw7Zy?=) Date: Wed, 14 Oct 2015 22:10:48 +0300 Subject: [Flask] Macro expansion/evaluation? In-Reply-To: <1170659701.351758.1444843186836.JavaMail.yahoo@mail.yahoo.com> References: <1170659701.351758.1444843186836.JavaMail.yahoo@mail.yahoo.com> <1170659701.351758.1444843186836.JavaMail.yahoo@mail.yahoo.com> Message-ID: See getattr and/or self.__dict__ 14 Ekim 2015 ?ar?amba tarihinde, Jim Icenhower via Flask yazd?: > Hi All, > I'm sure this is a newbie question but I haven't been able to find the > answer by searching. Probably because I don't know what this technique is > called in Python. > I have created a class which extends the Flask-Appbuilder Model class > which extends a SQLAlchemy class. I'm trying to validate that all required > fields are populated. I have created this function that returns all the > mapped attributes of the class: > > def get_obj_mapped_columns(dbObj): > mapper = inspect(dbObj) > return mapper.mapper.columns > > This is my main class: > > class Event(Model): > EventID = Column(Integer, primary_key=True) > EventKey = Column(String(30), unique=True, nullable=False) > Name = Column(String(100), nullable=False) > Description = Column(Text(1000), nullable=False) > BeginDate = Column(Date) > EndDate = Column(Date) > RegBeginDate = Column(Date) > RegEndDate = Column(Date) > Location = Column(String(200)) > Address1 = Column(String(200)) > Address2 = Column(String(200)) > City = Column(String(20)) > State = Column(String(2)) > Zip = Column(String(10)) > URL = Column(String(100)) > Email = Column(String(100)) > Phone = Column(String(20)) > > Which contains the following method: > > def isValid(self): > columns = get_obj_mapped_columns(self) > for column in columns: > if (NOT column.nullable): > print column.name > print self.*>* > > > I would like to substitute the value in in such a way that > it is evaluated as the field name of the Event object. > > Any guidance would be greatly appreciated! > > Thanks, > Jim > > Jim > -------------- next part -------------- An HTML attachment was scrubbed... URL: From 1316792450 at qq.com Tue Oct 13 14:09:04 2015 From: 1316792450 at qq.com (kk) Date: Tue, 13 Oct 2015 20:09:04 +0800 Subject: [Flask] Apply for register flask-restaction Message-ID: <3nZwfF0zQrzPCM@mail.python.org> Hi, I am developing a flask extension named flask-restaction, and I want to add it to flask extensions registry ( http://flask.pocoo.org/extensions/). Flask-restaction is a powerful flask ext for create restful api, you can see it at https://github.com/guyskk/flask-restaction. And it?s documents url is http://flask-restaction.readthedocs.org/zh/latest/. If you have any question, please contact me, thank you. yours sincerely, guyskk -------------- next part -------------- An HTML attachment was scrubbed... URL: From smcg4191 at mtneva.com Thu Oct 15 01:46:29 2015 From: smcg4191 at mtneva.com (S McGraw) Date: Wed, 14 Oct 2015 17:46:29 -0600 Subject: [Flask] urls when running under gunicorn In-Reply-To: References: <561D3EC1.8020300@mtneva.com> Message-ID: <561EE955.1060104@mtneva.com> I tried setting app.config['APPLICATION_ROOT'] (and verified it was set by running in a debugger) but it seemed to have no effect on the urls produced by url_for(), with or without the FixProxy middleware. The docs for url_for() say nothing about how they generate urls, and the "config" docs can be interpreted as saying APPLICATION_ROOT is only used when dealing with cookies. I glanced at the code for url_for() but it was way beyond me. So I am still rather at a loss... Have you (or anyone) actually used APPLICATION_ROOT to affect what url_for() produces? An affirmative answer will tell me I screwed up something here when trying to use it.) Thanks. On 10/13/2015 01:00 PM, Corey Boyle wrote: > I think what you are looking for is the "APPLICATION_ROOT" config item. > http://flask.pocoo.org/docs/0.10/config/ > > But don't take my word for it. > > On Tue, Oct 13, 2015 at 1:26 PM, S McGraw wrote: >> I new to flask and have a small first app working under flask's >> development server. In the templates I used url_for(), under the >> impression that would adjust the app's urls when I later run it >> behind a web server. >> >> I have now gotten it to run under gunicorn and set up a reverse >> proxy to it in my Apache (2.4) web server. It worked ok when >> configured as a virtual host. However, I want to run my app under >> a url in my regular url namespace, eg: >> http://myhost.com/myapp/(login,main,etc...) >> The trouble is that the urls in the rendered templates are still >> "/login", "/main", etc rather than /myapp/login, /myapp/main, etc >> which of course result in a 404 when clicked on. So I'm sure there >> is some step or piece of code I'm missing. >> >> FWIW, I tried using the werkzeug ProxyFix middleware suggested in >> the "Proxy Setups" section of the Flask docs, no effect. I saw >> recommendations to use Flask Snippets #35, along with configuring >> the web server to send certain headers, but they all seemed to be >> for Nginx, and seemed an awfully heavy-weight answer. Surely there >> is a simpler flask-only way to fix this? Also I read about Apache's >> mod_proxy_html but that too seems a little overkill to me.) >> >> I did get things to work by losing the url_for()'s in my code and >> templates, replaced with eg, g.prefix+'/main', where g.prefix is set >> to "/myapp" in a before_request() function. But I don't think that's >> the recommended practice. ;-) >> >> What am I missing? >> _______________________________________________ >> Flask mailing list >> Flask at python.org >> https://mail.python.org/mailman/listinfo/flask From coreybrett at gmail.com Thu Oct 15 16:04:01 2015 From: coreybrett at gmail.com (Corey Boyle) Date: Thu, 15 Oct 2015 10:04:01 -0400 Subject: [Flask] urls when running under gunicorn In-Reply-To: <561EE955.1060104@mtneva.com> References: <561D3EC1.8020300@mtneva.com> <561EE955.1060104@mtneva.com> Message-ID: So I added "SERVER_NAME" to my config, and it did change the urls produced by url_for. It also broke my app completely and made all links produce 404 errors. I don't know the answer to this problem. I would take a look at... http://flask.pocoo.org/docs/0.10/deploying/uwsgi/ http://gunicorn-docs.readthedocs.org/en/latest/deploy.html On Wed, Oct 14, 2015 at 7:46 PM, S McGraw wrote: > I tried setting app.config['APPLICATION_ROOT'] (and verified it was set > by running in a debugger) but it seemed to have no effect on the urls > produced by url_for(), with or without the FixProxy middleware. > The docs for url_for() say nothing about how they generate urls, and the > "config" docs can be interpreted as saying APPLICATION_ROOT is only used > when dealing with cookies. I glanced at the code for url_for() but it > was way beyond me. > > So I am still rather at a loss... Have you (or anyone) actually used > APPLICATION_ROOT to affect what url_for() produces? An affirmative > answer will tell me I screwed up something here when trying to use it.) > > Thanks. > > On 10/13/2015 01:00 PM, Corey Boyle wrote: >> I think what you are looking for is the "APPLICATION_ROOT" config item. >> http://flask.pocoo.org/docs/0.10/config/ >> >> But don't take my word for it. >> >> On Tue, Oct 13, 2015 at 1:26 PM, S McGraw wrote: >>> I new to flask and have a small first app working under flask's >>> development server. In the templates I used url_for(), under the >>> impression that would adjust the app's urls when I later run it >>> behind a web server. >>> >>> I have now gotten it to run under gunicorn and set up a reverse >>> proxy to it in my Apache (2.4) web server. It worked ok when >>> configured as a virtual host. However, I want to run my app under >>> a url in my regular url namespace, eg: >>> http://myhost.com/myapp/(login,main,etc...) >>> The trouble is that the urls in the rendered templates are still >>> "/login", "/main", etc rather than /myapp/login, /myapp/main, etc >>> which of course result in a 404 when clicked on. So I'm sure there >>> is some step or piece of code I'm missing. >>> >>> FWIW, I tried using the werkzeug ProxyFix middleware suggested in >>> the "Proxy Setups" section of the Flask docs, no effect. I saw >>> recommendations to use Flask Snippets #35, along with configuring >>> the web server to send certain headers, but they all seemed to be >>> for Nginx, and seemed an awfully heavy-weight answer. Surely there >>> is a simpler flask-only way to fix this? Also I read about Apache's >>> mod_proxy_html but that too seems a little overkill to me.) >>> >>> I did get things to work by losing the url_for()'s in my code and >>> templates, replaced with eg, g.prefix+'/main', where g.prefix is set >>> to "/myapp" in a before_request() function. But I don't think that's >>> the recommended practice. ;-) >>> >>> What am I missing? >>> _______________________________________________ >>> 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 From jeff at jeffwidman.com Thu Oct 15 22:35:17 2015 From: jeff at jeffwidman.com (Jeff Widman) Date: Thu, 15 Oct 2015 13:35:17 -0700 Subject: [Flask] flask uwsgi nginx deployment not working In-Reply-To: <5614535A.8080406@gmail.com> References: <5613F0E2.6020100@gmail.com> <5614535A.8080406@gmail.com> Message-ID: Sure, here's a blog post showing my working config for Flask + uWSGI Emperor + Nginx: http://www.jeffwidman.com/blog/802/serving-multiple-flask-apps-via-uwsgi-nginx/ Feel free to ask questions or suggest improvements... ? On Tue, Oct 6, 2015 at 4:03 PM, tigernassau wrote: > Hmm, looked at pull request - more confusion! Would try emperor but see > no docs on that - is your setup something you can post?. Otherwise we have > Bottle working nicely (and only seems to be missing session vs Flask, so it > might be easier to just get Beaker working with Bottle > > On 10/06/2015 03:03 PM, Jeff Widman wrote: > > I just setup Nginx + uWSGI + Flask the other day for the first time. > You're right, the Flask docs on uWSGI are outdated and use deprecated uWSGI > commands. There's a pull request in the Flask repo that shows the correct > way (as best I could tell) to set things up, it also covers the slightly > more complicated scenario of serving multiple Flask apps on a single uWSGI > socket. > > I take a cursory look through your code and nothing stuck out to me... I > used the Emperor option in place of the Master process option, as it gives > more flexibility, so maybe that's why I'm not seeing the specific issue... > maybe try that? > ? > > On Tue, Oct 6, 2015 at 9:03 AM, tigernassau wrote: > >> we can only get Flask to load on a debian server with nginx, uwsgi with a >> command line statement, not on server boot - yet we can get bottle to load >> just fine. >> >> most of the docs are either outdated, 80% complete, or different >> combinations (ie gunicorn, mod_wsgi, uwsgi-plugin-python, systemd ...) so >> we hope to write up a detailed set of docs that work for this combination >> >> Here's what we have: >> nginx.conf >> ..... >> upstream testapp { >> server localhost: 8082; >> } >> ..... >> location / { >> try_files $uri @wsgi; >> } >> location @wsgi { >> include /etc/nginx/uwsgi_params; >> uwsgi_pass testapp >> } >> ..... >> >> /etc/uwsgi/apps-enabled/testapp.ini >> [uwsgi] >> socket = localhost: 8082 >> chdir = /home/testapp >> file = app.py >> master = true >> plugins = python >> uid = www-data >> gid = www-data >> vacuum = true >> >> --- test command line run --- (works!) >> sudo uwsgi --socket 127.0.0.1:8082 --wsgi-file /home/testapp/app.py >> --callable app processes 4 --stats 127.0.0.1:9191 >> >> /etc/systemd/system/testapp.service >> [Unit] >> Description=wsgi flask testapp >> [Service] >> ExecStart=uwsgi --socket 127.0.0.1:8082 --wsgi-file /home/testapp/app.py >> --callable app --processes 4 >> Restart=always >> KillSignal=SIGQUIT >> Type=notify >> StandardError=syslog >> NotifyAccess=all >> >> [Install] >> WantedBy=multi-user.target >> >> sudo service testapp start ==> error >> >> The only difference we see between Flask not booting and Bottle working >> is in the app run statement >> Flask: >> if __name__ == '__main__': >> app.run() >> >> Bottle: >> if __name__ == '__main__': >> bottle.run(host="127.0.0.1",port=8082) >> else: >> app = application = bottle.default_app() >> >> >> maybe app run issue ?? >> maybe permission issue ?? (but wsgi ini works for bottle) >> maybe systemd service file ?? >> >> thks. >> >> -- >> Tiger Nassau, Inc. >> www.tigernassau.com >> >> _______________________________________________ >> Flask mailing list >> Flask at python.org >> https://mail.python.org/mailman/listinfo/flask >> > > > > -- > > * Jeff Widman* > jeffwidman.com | 740-WIDMAN-J (943-6265) > <>< > > > _______________________________________________ > Flask mailing listFlask at python.orghttps://mail.python.org/mailman/listinfo/flask > > > > -- > Tiger Nassau, Inc.www.tigernassau.com > > -- *Jeff Widman* jeffwidman.com | 740-WIDMAN-J (943-6265) <>< -------------- next part -------------- An HTML attachment was scrubbed... URL: From jab at math.brown.edu Fri Oct 16 17:10:43 2015 From: jab at math.brown.edu (jab at math.brown.edu) Date: Fri, 16 Oct 2015 11:10:43 -0400 Subject: [Flask] Jade instead of Jinja2 Message-ID: I just found this thread from August: On Tue Aug 18 21:04:50 CEST 2015, Alexandre Souza wrote: > Hello, Christophe. > I think Pyjade can be useful. Take a look: > https://github.com/alexandre/pyjade-example > > On Tue, Aug 18, 2015, at 12:47, Christophe Bal wrote: > >> I am new to Flask. Is there a good support for Jade tempting instead of >> Jinja2 ? How hard would be the task to build such a new plugin that can >> also add some feature specific to Jinja2 ? > > ...and thought I would cross-post the comment I just made on the stalled PyJade issue for mixin support: I was looking for something like PyJade for my Flask project, and thought > PyJade was the answer, but then found this issue and thought that not > having mixins/macros would be so limiting as to be a deal-breaker. It looks > like progress on this issue is stalled... In the meantime, I have to look > for an alternative. A little more searching turned up Plim > ; would anyone nominate > that or some other alternative? Using Plim with Flask looks > straightforward > , and IIUC > its def tag would > support the functionality that mixins in PyJade would. Can anyone on this list post any relevant experience reports, recommendations, etc.? Thanks, ?jab -------------- next part -------------- An HTML attachment was scrubbed... URL: From tigernassau at gmail.com Fri Oct 16 17:41:24 2015 From: tigernassau at gmail.com (tigernassau) Date: Fri, 16 Oct 2015 09:41:24 -0600 Subject: [Flask] flask uwsgi nginx deployment not working In-Reply-To: References: <5613F0E2.6020100@gmail.com> <5614535A.8080406@gmail.com> Message-ID: <56211AA4.4050703@gmail.com> thks for the post - looks like using emperor might be the key for flask with nginx - but still, it looks like a lot of pieces to put together and we have Bottle working fine so it's hard to justify the time to play more with Flask server side configs. From my professor side, I've learned that a tutorial post has to be really detailed, with every step by step shown, otherwise it requires the user/reader enormous amounts of time to play with and figure it all out. Actually we are now liking Bottle more than Flask - can't really see what we are missing by using Bottle since we are using straight psycopg sql calls instead of an ORM and aren't interested in using the WTF form stuff. Only thing we see missing is session. We looked at using pure postgres for session but going back to trying beaker + redis which I think is what Flask uses. I think if we wanted more of a framework for a programming group we would just move to Django. Sad, that the simple, get things done, micro frameworks like Bottle and Sinatra seem to get no love. Jeff, your post did lead to your blog site which has some pretty incredible blogs - some really great stuff there. On 10/15/2015 02:35 PM, Jeff Widman wrote: > Sure, here's a blog post showing my working config for Flask + uWSGI > Emperor + Nginx: > > http://www.jeffwidman.com/blog/802/serving-multiple-flask-apps-via-uwsgi-nginx/ > > Feel free to ask questions or suggest improvements... > ? > > On Tue, Oct 6, 2015 at 4:03 PM, tigernassau > wrote: > > Hmm, looked at pull request - more confusion! Would try emperor > but see no docs on that - is your setup something you can post?. > Otherwise we have Bottle working nicely (and only seems to be > missing session vs Flask, so it might be easier to just get Beaker > working with Bottle > > On 10/06/2015 03:03 PM, Jeff Widman wrote: >> I just setup Nginx + uWSGI + Flask the other day for the first >> time. You're right, the Flask docs on uWSGI are outdated and use >> deprecated uWSGI commands. There's a pull request in the Flask >> repo that shows the correct way (as best I could tell) to set >> things up, it also covers the slightly more complicated scenario >> of serving multiple Flask apps on a single uWSGI socket. >> >> I take a cursory look through your code and nothing stuck out to >> me... I used the Emperor option in place of the Master process >> option, as it gives more flexibility, so maybe that's why I'm not >> seeing the specific issue... maybe try that? >> ? >> >> On Tue, Oct 6, 2015 at 9:03 AM, tigernassau >> > wrote: >> >> we can only get Flask to load on a debian server with nginx, >> uwsgi with a command line statement, not on server boot - yet >> we can get bottle to load just fine. >> >> most of the docs are either outdated, 80% complete, or >> different combinations (ie gunicorn, mod_wsgi, >> uwsgi-plugin-python, systemd ...) so we hope to write up a >> detailed set of docs that work for this combination >> >> Here's what we have: >> nginx.conf >> ..... >> upstream testapp { >> server localhost: 8082; >> } >> ..... >> location / { >> try_files $uri @wsgi; >> } >> location @wsgi { >> include /etc/nginx/uwsgi_params; >> uwsgi_pass testapp >> } >> ..... >> >> /etc/uwsgi/apps-enabled/testapp.ini >> [uwsgi] >> socket = localhost: 8082 >> chdir = /home/testapp >> file = app.py >> master = true >> plugins = python >> uid = www-data >> gid = www-data >> vacuum = true >> >> --- test command line run --- (works!) >> sudo uwsgi --socket 127.0.0.1:8082 >> --wsgi-file /home/testapp/app.py --callable app processes 4 >> --stats 127.0.0.1:9191 >> >> /etc/systemd/system/testapp.service >> [Unit] >> Description=wsgi flask testapp >> [Service] >> ExecStart=uwsgi --socket 127.0.0.1:8082 >> --wsgi-file /home/testapp/app.py >> --callable app --processes 4 >> Restart=always >> KillSignal=SIGQUIT >> Type=notify >> StandardError=syslog >> NotifyAccess=all >> >> [Install] >> WantedBy=multi-user.target >> >> sudo service testapp start ==> error >> >> The only difference we see between Flask not booting and >> Bottle working is in the app run statement >> Flask: >> if __name__ == '__main__': >> app.run() >> >> Bottle: >> if __name__ == '__main__': >> bottle.run(host="127.0.0.1",port=8082) >> else: >> app = application = bottle.default_app() >> >> >> maybe app run issue ?? >> maybe permission issue ?? (but wsgi ini works for bottle) >> maybe systemd service file ?? >> >> thks. >> >> -- >> Tiger Nassau, Inc. >> www.tigernassau.com >> >> _______________________________________________ >> Flask mailing list >> Flask at python.org >> https://mail.python.org/mailman/listinfo/flask >> >> >> >> >> -- >> * >> Jeff Widman* >> jeffwidman.com | 740-WIDMAN-J >> (943-6265) >> <>< >> >> >> _______________________________________________ >> Flask mailing list >> Flask at python.org >> https://mail.python.org/mailman/listinfo/flask > > > -- > Tiger Nassau, Inc. > www.tigernassau.com > > > > > -- > * > Jeff Widman* > jeffwidman.com | 740-WIDMAN-J (943-6265) > <>< -- Tiger Nassau, Inc. www.tigernassau.com -------------- next part -------------- An HTML attachment was scrubbed... URL: From jicenhower at yahoo.com Mon Oct 19 15:00:21 2015 From: jicenhower at yahoo.com (Jim Icenhower) Date: Mon, 19 Oct 2015 13:00:21 +0000 (UTC) Subject: [Flask] Can I write my own WTF file validator? References: <1519816480.2398197.1445259621382.JavaMail.yahoo@mail.yahoo.com> Message-ID: <1519816480.2398197.1445259621382.JavaMail.yahoo@mail.yahoo.com> Hi,I'm creating an import using Flask, WTF and Flask Appbuilder. I see that the Flask WTF FileField allows validators. Can I create my own? I want to check that required fields are populated on every record in the uploaded file. I'd like to pass a class to the validator that contains the required fields so I can use this routine for many different record types.I think I'd like to do something like this:class UploadForm(Form): upload = FileField("Upload your Events file", validators=[file_required(), file_required_fields(Events, "Images only!")])Is this possible? If so, what class to I extend/inherit from to create my validator? I'm a Java developer but a total newbie to Python/Flask. Thanks! Jim -------------- next part -------------- An HTML attachment was scrubbed... URL: From tigernassau at gmail.com Mon Oct 19 16:46:02 2015 From: tigernassau at gmail.com (Tiger Nassau) Date: Mon, 19 Oct 2015 08:46:02 -0600 Subject: [Flask] Can I write my own WTF file validator? In-Reply-To: <1519816480.2398197.1445259621382.JavaMail.yahoo@mail.yahoo.com> References: <1519816480.2398197.1445259621382.JavaMail.yahoo@mail.yahoo.com> <1519816480.2398197.1445259621382.JavaMail.yahoo@mail.yahoo.com> Message-ID: <897bc98f-8bf2-46c3-9279-1a83f5a3a447@email.typeapp.com> you must be a windows person (: this is open source and you can do anything you want to your app - just try out your idea and test - its only form stuff so should not break too much of the app if it does not work?? post any specific errors and others can help more if you get it working and think it will benefit others then post a blog and submit the code via a pull request Sent from Type Mail On Oct 19, 2015, 07:02, at 07:02, Jim Icenhower via Flask wrote: >Hi,I'm creating an import using Flask, WTF and Flask Appbuilder. I see >that the Flask WTF FileField allows validators. Can I create my own? I >want to check that required fields are populated on every record in the >uploaded file. I'd like to pass a class to the validator that contains >the required fields so I can use this routine for many different record >types.I think I'd like to do something like this:class >UploadForm(Form): > upload = FileField("Upload your Events file", > validators=[file_required(), >file_required_fields(Events, "Images only!")])Is this possible? If so, >what class to I extend/inherit from to create my validator? I'm a Java >developer but a total newbie to Python/Flask. >Thanks! >Jim > >------------------------------------------------------------------------ > >_______________________________________________ >Flask mailing list >Flask at python.org >https://mail.python.org/mailman/listinfo/flask -------------- next part -------------- An HTML attachment was scrubbed... URL: From david at davidbaumgold.com Mon Oct 19 16:48:49 2015 From: david at davidbaumgold.com (David Baumgold) Date: Mon, 19 Oct 2015 10:48:49 -0400 Subject: [Flask] Can I write my own WTF file validator? In-Reply-To: <897bc98f-8bf2-46c3-9279-1a83f5a3a447@email.typeapp.com> References: <1519816480.2398197.1445259621382.JavaMail.yahoo@mail.yahoo.com> <1519816480.2398197.1445259621382.JavaMail.yahoo@mail.yahoo.com> <897bc98f-8bf2-46c3-9279-1a83f5a3a447@email.typeapp.com> Message-ID: Jim, here?s the documentation for writing custom validators:?http://wtforms.readthedocs.org/en/latest/validators.html#custom-validators From:?Tiger Nassau Reply:?Tiger Nassau Date:?October 19, 2015 at 10:46:22 AM To:?Jim Icenhower CC:?flask at python.org Subject:? Re: [Flask] Can I write my own WTF file validator? you must be a windows person (: this is open source and you can do anything you want to your app - just try out your idea and test - its only form stuff so should not break too much of the app if it does not work?? post any specific errors and others can help more if you get it working and think it will benefit others then post a blog and submit the code via a pull request Sent from Type Mail On Oct 19, 2015, at 07:02, Jim Icenhower via Flask wrote: Hi, I'm creating an import using Flask, WTF and Flask Appbuilder. I see that the Flask WTF FileField allows validators. Can I create my own? I want to check that required fields are populated on every record in the uploaded file. I'd like to pass a class to the validator that contains the required fields so I can use this routine for many different record types. I think I'd like to do something like this: class UploadForm(Form): upload = FileField("Upload your Events file", validators=[file_required(), file_required_fields(Events, "Images only!")]) Is this possible? If so, what class to I extend/inherit from to create my validator? I'm a Java developer but a total newbie to Python/Flask. Thanks! Jim 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 ZDunlap at ap.org Mon Oct 19 17:24:27 2015 From: ZDunlap at ap.org (Dunlap, Zachariah) Date: Mon, 19 Oct 2015 15:24:27 +0000 Subject: [Flask] app.route not found serving applicaiton w/Apache & mod_wsgi Message-ID: Hello Flask mailing list, I'm new to Flask so I have no doubt many of you will have great suggestions on how to fix my issue. I have a simple web app which responds to an HTML form containing some selections that return links for Amazon S3 folders. I've used JavaScript to return the results on the same page to make it an easier experience for users (this is an internal only app, it won't go out to the live web). The app is basically structured like this (edited to keep this message as short as possible): @app.route('/generate_urls', methods = ['GET', 'POST']) def generate_urls(): BUNCH OF CODE HERE (REMOVED FOR BREVITY) return RETURN_STUFF @app.route('/') def index(): return render_template('index.html') if __name__ == '__main__': app.run(host='0.0.0.0', port=1234) My folder structure for the app looks like this: app folder --app_name.py --static (folder) ----css (folder) ------css_file.css ----js (folder) ------js_file.js When I serve the app using the dev method, everything works great with no issues. Now I'm working on using Apache and mod_wsgi to serve the app with a friendly URL and the homepage is served without issue once I've configured everything but when I attempt to use the form to create the links, I get an error from Apache that says: Not Found The requested URL /generate_urls was not found on this server. This leads me to believe it doesn't know what to do with the @app.route() call. I'm sure I'm missing something and may need to approach this differently, but I haven't had much luck figuring that out on my own yet. Any help with this would be greatly appreciated. Thanks, Zach The information contained in this communication is intended for the use of the designated recipients named above. If the reader of this communication is not the intended recipient, you are hereby notified that you have received this communication in error, and that any review, dissemination, distribution or copying of this communication is strictly prohibited. If you have received this communication in error, please notify The Associated Press immediately by telephone at +1-212-621-1898 and delete this email. Thank you. [IP_US_DISC] msk dccc60c6d2c3a6438f0cf467d9a4938 -------------- next part -------------- An HTML attachment was scrubbed... URL: From david at davidbaumgold.com Mon Oct 19 17:36:35 2015 From: david at davidbaumgold.com (David Baumgold) Date: Mon, 19 Oct 2015 11:36:35 -0400 Subject: [Flask] app.route not found serving applicaiton w/Apache & mod_wsgi In-Reply-To: References: Message-ID: You say you?ve configured Apache to serve the application with a friendly URL. Does that mean that Apache is rewriting URLs for you? It could be that when you direct the user to /generate_urls on your application, Apache is rewriting it somehow so that Flask doesn?t see that it matches one of the URL routes you?ve set up. Without seeing more of your code, I can?t tell. Also, have you configured Apache properly as per the documentation??http://flask.pocoo.org/docs/0.10/deploying/mod_wsgi/ David Baumgold From:?Dunlap, Zachariah Reply:?Dunlap, Zachariah Date:?October 19, 2015 at 11:25:56 AM To:?flask at python.org Subject:? [Flask] app.route not found serving applicaiton w/Apache & mod_wsgi Hello Flask mailing list, ? I?m new to Flask so I have no doubt many of you will have great suggestions on how to fix my issue. ? I have a simple web app which responds to an HTML form containing some selections that return links for Amazon S3 folders. I?ve used JavaScript to return the results on the same page to make it an easier experience for users (this is an internal only app, it won?t go out to the live web). ? The app is basically structured like this (edited to keep this message as short as possible): ? @app.route('/generate_urls', methods = ['GET', 'POST']) def generate_urls(): ? BUNCH OF CODE HERE (REMOVED FOR BREVITY) ??return RETURN_STUFF ? @app.route('/') def index(): ? return render_template('index.html') ? if __name__ == '__main__': ? app.run(host='0.0.0.0', port=1234) ? My folder structure for the app looks like this: ? app folder --app_name.py --static (folder) ----css (folder) ------css_file.css ----js (folder) ------js_file.js ? When I serve the app using the dev method, everything works great with no issues. ? Now I?m working on using Apache and mod_wsgi to serve the app with a friendly URL and the homepage is served without issue once I?ve configured everything but when I attempt to use the form to create the links, I get an error from Apache that says: ? Not Found The requested URL /generate_urls was not found on this server. This leads me to believe it doesn?t know what to do with the @app.route() call. ? I?m sure I?m missing something and may need to approach this differently, but I haven?t had much luck figuring that out on my own yet. ? Any help with this would be greatly appreciated. ? Thanks, Zach ? ? The information contained in this communication is intended for the use of the designated recipients named above. If the reader of this communication is not the intended recipient, you are hereby notified that you have received this communication in error, and that any review, dissemination, distribution or copying of this communication is strictly prohibited. If you have received this communication in error, please notify The Associated Press immediately by telephone at +1-212-621-1898 and delete this email. Thank you. [IP_US_DISC] msk dccc60c6d2c3a6438f0cf467d9a4938 _______________________________________________ Flask mailing list Flask at python.org https://mail.python.org/mailman/listinfo/flask -------------- next part -------------- An HTML attachment was scrubbed... URL: From ZDunlap at ap.org Mon Oct 19 18:10:33 2015 From: ZDunlap at ap.org (Dunlap, Zachariah) Date: Mon, 19 Oct 2015 16:10:33 +0000 Subject: [Flask] app.route not found serving applicaiton w/Apache & mod_wsgi In-Reply-To: References: Message-ID: Thanks David, Answers to your questions: 1. Yes, I?m using Apache to rewrite URLs. 2. I?m fairly sure I configured Apache correctly, I?m using Apache via WAMP on a Windows server (unfortunately my hands are tied to using Windows for now due to my company) Apache configuration looks like this, note that using: Order deny,allow & Allow from all gave me a, you do not have access error so I changed that as you?ll see below (maybe this is also wrong?): ServerName localhost WSGIScriptAlias /friendly-url d:/zachs_app/zachs_excellent_wsgi_file Require all granted If you need more code let me know and I can provide a more complete example. The only things missing from the Python below though are the imports, calls to S3 using the Boto library and calls using the requests library. Thanks very much for taking a look. Regards, Zach From: David Baumgold [mailto:david at davidbaumgold.com] Sent: Monday, October 19, 2015 11:37 AM To: flask at python.org; Dunlap, Zachariah Subject: Re: [Flask] app.route not found serving applicaiton w/Apache & mod_wsgi You say you?ve configured Apache to serve the application with a friendly URL. Does that mean that Apache is rewriting URLs for you? It could be that when you direct the user to /generate_urls on your application, Apache is rewriting it somehow so that Flask doesn?t see that it matches one of the URL routes you?ve set up. Without seeing more of your code, I can?t tell. Also, have you configured Apache properly as per the documentation? http://flask.pocoo.org/docs/0.10/deploying/mod_wsgi/ David Baumgold From: Dunlap, Zachariah Reply: Dunlap, Zachariah Date: October 19, 2015 at 11:25:56 AM To: flask at python.org Subject: [Flask] app.route not found serving applicaiton w/Apache & mod_wsgi Hello Flask mailing list, I?m new to Flask so I have no doubt many of you will have great suggestions on how to fix my issue. I have a simple web app which responds to an HTML form containing some selections that return links for Amazon S3 folders. I?ve used JavaScript to return the results on the same page to make it an easier experience for users (this is an internal only app, it won?t go out to the live web). The app is basically structured like this (edited to keep this message as short as possible): @app.route('/generate_urls', methods = ['GET', 'POST']) def generate_urls(): BUNCH OF CODE HERE (REMOVED FOR BREVITY) return RETURN_STUFF @app.route('/') def index(): return render_template('index.html') if __name__ == '__main__': app.run(host='0.0.0.0', port=1234) My folder structure for the app looks like this: app folder --app_name.py --static (folder) ----css (folder) ------css_file.css ----js (folder) ------js_file.js When I serve the app using the dev method, everything works great with no issues. Now I?m working on using Apache and mod_wsgi to serve the app with a friendly URL and the homepage is served without issue once I?ve configured everything but when I attempt to use the form to create the links, I get an error from Apache that says: Not Found The requested URL /generate_urls was not found on this server. This leads me to believe it doesn?t know what to do with the @app.route() call. I?m sure I?m missing something and may need to approach this differently, but I haven?t had much luck figuring that out on my own yet. Any help with this would be greatly appreciated. Thanks, Zach The information contained in this communication is intended for the use of the designated recipients named above. If the reader of this communication is not the intended recipient, you are hereby notified that you have received this communication in error, and that any review, dissemination, distribution or copying of this communication is strictly prohibited. If you have received this communication in error, please notify The Associated Press immediately by telephone at +1-212-621-1898 and delete this email. Thank you. [IP_US_DISC] msk dccc60c6d2c3a6438f0cf467d9a4938 _______________________________________________ Flask mailing list Flask at python.org https://mail.python.org/mailman/listinfo/flask -------------- next part -------------- An HTML attachment was scrubbed... URL: From ZDunlap at ap.org Mon Oct 19 18:13:47 2015 From: ZDunlap at ap.org (Dunlap, Zachariah) Date: Mon, 19 Oct 2015 16:13:47 +0000 Subject: [Flask] app.route not found serving applicaiton w/Apache & mod_wsgi In-Reply-To: References: Message-ID: Sorry forgot to include what the wsgi file looks like: import sys sys.path.append("d:/zachs_app") from zach_app import app as application From: Flask [mailto:flask-bounces+zdunlap=ap.org at python.org] On Behalf Of Dunlap, Zachariah Sent: Monday, October 19, 2015 12:11 PM To: David Baumgold; flask at python.org Subject: Re: [Flask] app.route not found serving applicaiton w/Apache & mod_wsgi Thanks David, Answers to your questions: 1. Yes, I?m using Apache to rewrite URLs. 2. I?m fairly sure I configured Apache correctly, I?m using Apache via WAMP on a Windows server (unfortunately my hands are tied to using Windows for now due to my company) Apache configuration looks like this, note that using: Order deny,allow & Allow from all gave me a, you do not have access error so I changed that as you?ll see below (maybe this is also wrong?): ServerName localhost WSGIScriptAlias /friendly-url d:/zachs_app/zachs_excellent_wsgi_file Require all granted If you need more code let me know and I can provide a more complete example. The only things missing from the Python below though are the imports, calls to S3 using the Boto library and calls using the requests library. Thanks very much for taking a look. Regards, Zach From: David Baumgold [mailto:david at davidbaumgold.com] Sent: Monday, October 19, 2015 11:37 AM To: flask at python.org; Dunlap, Zachariah Subject: Re: [Flask] app.route not found serving applicaiton w/Apache & mod_wsgi You say you?ve configured Apache to serve the application with a friendly URL. Does that mean that Apache is rewriting URLs for you? It could be that when you direct the user to /generate_urls on your application, Apache is rewriting it somehow so that Flask doesn?t see that it matches one of the URL routes you?ve set up. Without seeing more of your code, I can?t tell. Also, have you configured Apache properly as per the documentation? http://flask.pocoo.org/docs/0.10/deploying/mod_wsgi/ David Baumgold From: Dunlap, Zachariah Reply: Dunlap, Zachariah Date: October 19, 2015 at 11:25:56 AM To: flask at python.org Subject: [Flask] app.route not found serving applicaiton w/Apache & mod_wsgi Hello Flask mailing list, I?m new to Flask so I have no doubt many of you will have great suggestions on how to fix my issue. I have a simple web app which responds to an HTML form containing some selections that return links for Amazon S3 folders. I?ve used JavaScript to return the results on the same page to make it an easier experience for users (this is an internal only app, it won?t go out to the live web). The app is basically structured like this (edited to keep this message as short as possible): @app.route('/generate_urls', methods = ['GET', 'POST']) def generate_urls(): BUNCH OF CODE HERE (REMOVED FOR BREVITY) return RETURN_STUFF @app.route('/') def index(): return render_template('index.html') if __name__ == '__main__': app.run(host='0.0.0.0', port=1234) My folder structure for the app looks like this: app folder --app_name.py --static (folder) ----css (folder) ------css_file.css ----js (folder) ------js_file.js When I serve the app using the dev method, everything works great with no issues. Now I?m working on using Apache and mod_wsgi to serve the app with a friendly URL and the homepage is served without issue once I?ve configured everything but when I attempt to use the form to create the links, I get an error from Apache that says: Not Found The requested URL /generate_urls was not found on this server. This leads me to believe it doesn?t know what to do with the @app.route() call. I?m sure I?m missing something and may need to approach this differently, but I haven?t had much luck figuring that out on my own yet. Any help with this would be greatly appreciated. Thanks, Zach The information contained in this communication is intended for the use of the designated recipients named above. If the reader of this communication is not the intended recipient, you are hereby notified that you have received this communication in error, and that any review, dissemination, distribution or copying of this communication is strictly prohibited. If you have received this communication in error, please notify The Associated Press immediately by telephone at +1-212-621-1898 and delete this email. Thank you. [IP_US_DISC] msk dccc60c6d2c3a6438f0cf467d9a4938 _______________________________________________ Flask mailing list Flask at python.org https://mail.python.org/mailman/listinfo/flask -------------- next part -------------- An HTML attachment was scrubbed... URL: From tigernassau at gmail.com Tue Oct 20 20:34:30 2015 From: tigernassau at gmail.com (tigernassau) Date: Tue, 20 Oct 2015 12:34:30 -0600 Subject: [Flask] errors w/ flask deployment with emperor Message-ID: <56268936.6040803@gmail.com> okay, we took another try at getting flask to deploy using emperor server: debian 8, using python3 server runs bottle apps fine here is the config we tried - get error: "curse the vassal... /etc/uwsgi/vassals/testapp.ini couldn't find any more details on what is wrong btw had to run uwsgi emperor as sudo since the systemd service failed with log file permission error ---- w/ flask --- # sudo apt-get install python3-dev # sudo apt-get install python3-pip # sudo pip3 install flask # sudo pip3 install py-bcrypt # sudo pip3 install psycopg2 # sudo pip3 install uwsgi # sudo apt-get install uwsgi-plugin-python sudo vim /etc/nginx/nginx.conf user nginx; worker processes 5 ..... http { ... server { listen 80; server_name testapp.com www.testapp.com; root /home/testapp; charset utf-8; location /static { alias /home/testapp/static; } location = /favico.ico { root /home/testapp/static/images/favico.ico; } location / { try_files $uri @wsgi; } location @wsgi { include /etc/nginx/uwsgi_params; uwsgi_pass unix:/home/testapp/testapp.sock; } } } #http sudo service nginx configtest sudo service nginx start (stop reload) ---- uwsgi-emperor --- sudo vim /etc/uwsgi/emperor.ini [uwsgi] emperor = /etc/uwsgi/vassals master = true #plugins = python2 #uid = www-data #gid = www-data --- uwsgi vassals --- sudo vim /etc/uwsgi/vassals/testapp.ini [uwsgi] chdir = /home/testapp socket = /home/testapp/testapp.sock chmod-socket = 664 file = app.py callable = app processes = 4 stats = 127.0.0.1:9191 max-requests = 5000 #master = true #plugins = python #uid = www-data #gid = www-data vacuum = true thunder-lock = true enable-threads = true logto = /var/log/uwsgi/testapp.log # die-on-term = true ---- systemd service emperor --- sudo vim /etc/systemd/system/testapp.service [Unit] Description=uwsgi emperor for testapp After=network.target [Service] User=www-data Group=www-data WorkingDirectory=/home/testapp ExecStart=uwsgi --emperor /etc/uwsgi/vassals/testapp.ini --logto /var/log/uwsgi/testapp.log #[Install] #WantedBy=multi-user.target -- Tiger Nassau, Inc. www.tigernassau.com From amriabdesslem at gmail.com Wed Oct 21 01:10:45 2015 From: amriabdesslem at gmail.com (Abdesslem Amri) Date: Wed, 21 Oct 2015 00:10:45 +0100 Subject: [Flask] (no subject) In-Reply-To: References: Message-ID: I think that you are using a local checkout.js file. You have to use this file https://checkout.stripe.com/checkout.js 2015-10-01 20:01 GMT+01:00 Christophe Bal : > Yes ... not in ... Is more pythonic. > Le 30 sept. 2015 21:57, "Dorian Hoxha" a ?crit : > >> From a quick look, don't store config values in the code. >> Careful with stripe keys (they look like test keys though) >> >> I think it's more pythonic: >> if 'a' not in b >> >> instead of : >> >> if not 'a' in b: >> >> I'm not sure though. >> >> On Wed, Sep 30, 2015 at 9:28 PM, Kyle Lawlor >> wrote: >> >>> Ok, I will look into this first. Thanks again for the pointers. In the >>> meantime, any further comments still appreciated. >>> >>> On Wed, Sep 30, 2015 at 2:34 PM, Dorian Hoxha >>> wrote: >>> >>>> Replace the code like I said and try again if the error persist. >>>> I don't know if the fields do(nt) exist in your code, that's why you >>>> have to fix them by actually checking. >>>> >>>> On Wed, Sep 30, 2015 at 8:01 PM, Kyle Lawlor >>>> wrote: >>>> >>>>> Ok. Thanks for the response. I will keep this in mind as I continue to >>>>> diagnose my problem. Did you spot a place in my code where the field d.n.e.? >>>>> >>>>> On Wed, Sep 30, 2015 at 9:35 AM, Dorian Hoxha >>>>> wrote: >>>>> >>>>>> ALWAYS check if the field exist in request.form, if it doesn't you >>>>>> will get a 400 request-error. >>>>>> 2 ways to check: >>>>>> if 'field' in request.form >>>>>> if request.form.get('field') >>>>>> >>>>>> On Wed, Sep 30, 2015 at 12:29 AM, Kyle Lawlor >>>>>> wrote: >>>>>> >>>>>>> Hello, everyone. >>>>>>> >>>>>>> I've been working on web app for a friends restaurant. I am slowly >>>>>>> adding the functionality that I need. Earlier today I was able to add a >>>>>>> payment method via the Stripe API. I have confirmed that the test payments >>>>>>> are going through to my Stripe logs. I followed very closely to the [stripe >>>>>>> flask tutorial](https://stripe.com/docs/checkout/guides/flask). >>>>>>> Basically I am doing the exact same thing as what is done in the tutorial, >>>>>>> except I have adjusted the payment amount based on interaction with the >>>>>>> "order online" portion of the website. >>>>>>> >>>>>>> >>>>>>> *First issue:* >>>>>>> >>>>>>> One issue I am having (which I am sure is just a stupid mistake) is >>>>>>> that once the purchase is confirmed, I redirect to a confirmation page to >>>>>>> show a summary of the order, but I am getting a "400 Bad Request - CSRF >>>>>>> token missing or incorrect" error. >>>>>>> >>>>>>> I tried to solve the problem using the methods from [this page]( >>>>>>> http://flask-wtf.readthedocs.org/en/latest/csrf.html), like adding >>>>>>> an empty form with a CSRF token, to no avail. I also tried including a meta >>>>>>> tag with the token which also did not work. >>>>>>> >>>>>>> I am puzzled. A curious thing is that I can access the "payment" >>>>>>> page manually via url before and after the transaction goes through. It >>>>>>> seems that the trouble only happens when I redirect from the Stripe payment. >>>>>>> >>>>>>> *Second issue:* >>>>>>> >>>>>>> Another possibly related issue is that there is a segment of code >>>>>>> using the stripe API I have commented out for the following reason. When it >>>>>>> is uncommented I get the following error in addition to the CSRF error >>>>>>> stated above, "400 Bad Request - The browser (or proxy) sent a request that >>>>>>> this server could not understand." >>>>>>> >>>>>>> If anyone has a chance to take a look at this for me it would be >>>>>>> greatly appreciated. Here is the latest version of the project (currently >>>>>>> using the meta tag with CSRF). >>>>>>> >>>>>>> *Project:* https://github.com/callmeskywalker/casa-site >>>>>>> >>>>>>> >>>>>>> >>>>>>> *First issue relevant:* >>>>>>> stripe import and test keys: >>>>>>> >>>>>>> https://github.com/callmeskywalker/casa-site/blob/master/app/main/views.py#L38-L43 >>>>>>> >>>>>>> order view function: >>>>>>> >>>>>>> https://github.com/callmeskywalker/casa-site/blob/master/app/main/views.py#L47-L128 >>>>>>> >>>>>>> >>>>>>> pass stripe key to 'order' template: >>>>>>> >>>>>>> https://github.com/callmeskywalker/casa-site/blob/master/app/main/views.py#L128 >>>>>>> >>>>>>> stripe implementation in 'order' template: >>>>>>> >>>>>>> https://github.com/callmeskywalker/casa-site/blob/master/app/templates/order.html#L50-L64 >>>>>>> >>>>>>> action to redirect to the 'payment' template (just to display order >>>>>>> details): >>>>>>> >>>>>>> https://github.com/callmeskywalker/casa-site/blob/master/app/templates/order.html#L51 >>>>>>> >>>>>>> payment template with csrf token: >>>>>>> >>>>>>> https://github.com/callmeskywalker/casa-site/blob/master/app/templates/payment.html#L5 >>>>>>> >>>>>>> *Second issue relevant:* >>>>>>> >>>>>>> code from stripe API in payment view function (causing second error): >>>>>>> >>>>>>> https://github.com/callmeskywalker/casa-site/blob/master/app/main/views.py#L138-L148 >>>>>>> >>>>>>> >>>>>>> Thanks ahead. I look forward to any responses. >>>>>>> >>>>>>> Best, >>>>>>> Kyle >>>>>>> >>>>>>> >>>>>>> _______________________________________________ >>>>>>> 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 >> >> > _______________________________________________ > Flask mailing list > Flask at python.org > https://mail.python.org/mailman/listinfo/flask > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From tigernassau at gmail.com Wed Oct 21 01:10:55 2015 From: tigernassau at gmail.com (tigernassau) Date: Tue, 20 Oct 2015 17:10:55 -0600 Subject: [Flask] errors w/ flask deployment with emperor In-Reply-To: References: <56268936.6040803@gmail.com> Message-ID: <5626C9FF.7020305@gmail.com> thks okay we can try "module" - hmm, will app.py do ? or do we need to use __init__.py ? and spec python3 ? right now our __init__.py is empty is it a good idea to run emperor as root ? run anything as root ? when we ran a test, it gave us a warning msg about running as root On 10/20/2015 01:25 PM, Jeff Widman wrote: > A few quick things I noticed: > - no need to set Master = True in your Emperor because functionally > the Emperor IS the master process. I submitted a pull request to the > uWSGI docs clarifying this last week. > - Emperor is generally run as root, with the vassals specifying their > UID/GID. That lets the Emperor respawn vassals for various > UID/GID's--for security, it will drop the vassal's privileges before > actually serving requests > > I noticed you're trying to call Flask using the 'file' + 'callable' > params. Typically most examples I've seen just use 'module' + > 'callable'. I haven't looked into the 'file' param, it may do the same > thing. The most important part is making sure you're calling whatever > it is that starts your app... sometimes people subclass app in a > different file, particularly if they're using the app factory pattern > for quickly switching between dev and prod configuration. > > To debug, I'd first try running the Flask development webserver, and > make sure it loads. That should allow you to trace whether you should > be calling 'app' or a different command. Then try the vassal by itself > using the shell and see if it loads, then if that works then add the > emperor, then if that all works, then go to daemonizing it using SystemD. > > Cheers, > Jeff > > ? > > On Tue, Oct 20, 2015 at 11:34 AM, tigernassau > wrote: > > okay, we took another try at getting flask to deploy using emperor > server: debian 8, using python3 > > server runs bottle apps fine > > here is the config we tried - get error: "curse the vassal... > /etc/uwsgi/vassals/testapp.ini > couldn't find any more details on what is wrong > > btw had to run uwsgi emperor as sudo since the systemd service > failed with log file permission error > > ---- w/ flask --- > # sudo apt-get install python3-dev > # sudo apt-get install python3-pip > # sudo pip3 install flask > # sudo pip3 install py-bcrypt > # sudo pip3 install psycopg2 > # sudo pip3 install uwsgi > # sudo apt-get install uwsgi-plugin-python > > sudo vim /etc/nginx/nginx.conf > user nginx; > worker processes 5 > ..... > http { > ... > server { > listen 80; > server_name testapp.com > www.testapp.com ; > root /home/testapp; > charset utf-8; > location /static { > alias /home/testapp/static; > } > location = /favico.ico { > root /home/testapp/static/images/favico.ico; > } > location / { > try_files $uri @wsgi; > } > location @wsgi { > include /etc/nginx/uwsgi_params; > uwsgi_pass unix:/home/testapp/testapp.sock; > } > } > } #http > sudo service nginx configtest > sudo service nginx start (stop reload) > > ---- uwsgi-emperor --- > sudo vim /etc/uwsgi/emperor.ini > [uwsgi] > emperor = /etc/uwsgi/vassals > master = true > #plugins = python2 > #uid = www-data > #gid = www-data > > --- uwsgi vassals --- > sudo vim /etc/uwsgi/vassals/testapp.ini > [uwsgi] > chdir = /home/testapp > socket = /home/testapp/testapp.sock > chmod-socket = 664 > file = app.py > callable = app > processes = 4 > stats = 127.0.0.1:9191 > max-requests = 5000 > #master = true > #plugins = python > #uid = www-data > #gid = www-data > vacuum = true > thunder-lock = true > enable-threads = true > logto = /var/log/uwsgi/testapp.log > # die-on-term = true > > ---- systemd service emperor --- > sudo vim /etc/systemd/system/testapp.service > [Unit] > Description=uwsgi emperor for testapp > After=network.target > [Service] > User=www-data > Group=www-data > WorkingDirectory=/home/testapp > ExecStart=uwsgi --emperor /etc/uwsgi/vassals/testapp.ini --logto > /var/log/uwsgi/testapp.log > #[Install] > #WantedBy=multi-user.target > > > > > > > -- > Tiger Nassau, Inc. > www.tigernassau.com > > _______________________________________________ > Flask mailing list > Flask at python.org > https://mail.python.org/mailman/listinfo/flask > > > > > -- > * > Jeff Widman* > jeffwidman.com | 740-WIDMAN-J (943-6265) > <>< -- Tiger Nassau, Inc. www.tigernassau.com -------------- next part -------------- An HTML attachment was scrubbed... URL: From tigernassau at gmail.com Mon Oct 26 13:59:17 2015 From: tigernassau at gmail.com (tigernassau) Date: Mon, 26 Oct 2015 11:59:17 -0600 Subject: [Flask] Deploying Flask Solved With Waitress Message-ID: <562E69F5.80500@gmail.com> Had way too much trouble with uwsgi - found Waitress - a pure wsgi server this site showed how easy it is to use with Flask http://gr33ndata.blogspot.com/2012/01/waitress-flask.html Simple - in 2 minutes had Flask deployed with a simple systemd script to run python3 app.py -- Tiger Nassau, Inc. www.tigernassau.com From coreybrett at gmail.com Tue Oct 27 15:29:14 2015 From: coreybrett at gmail.com (Corey Boyle) Date: Tue, 27 Oct 2015 15:29:14 -0400 Subject: [Flask] Deploying Flask Solved With Waitress In-Reply-To: <562E69F5.80500@gmail.com> References: <562E69F5.80500@gmail.com> Message-ID: I gave waitress a try today and it seems to work great at first. However, I'm now noticing that I am "in-consistently" having issues with my CSRF token and occasionally getting logged out of the web app. I suspect this has something to do with how the cookies are getting handled. Has anyone else had this type of trouble with waitress? On Mon, Oct 26, 2015 at 1:59 PM, tigernassau wrote: > Had way too much trouble with uwsgi - found Waitress - a pure wsgi server > this site showed how easy it is to use with Flask > http://gr33ndata.blogspot.com/2012/01/waitress-flask.html > > > > Simple - in 2 minutes had Flask deployed with a simple systemd script to run > python3 app.py > > -- > Tiger Nassau, Inc. > www.tigernassau.com > > _______________________________________________ > Flask mailing list > Flask at python.org > https://mail.python.org/mailman/listinfo/flask From dorian.hoxha at gmail.com Wed Oct 28 09:16:13 2015 From: dorian.hoxha at gmail.com (Dorian Hoxha) Date: Wed, 28 Oct 2015 14:16:13 +0100 Subject: [Flask] Deploying Flask Solved With Waitress In-Reply-To: References: <562E69F5.80500@gmail.com> Message-ID: What trouble did you have with uwsgi? Did you read this page: https://uwsgi-docs.readthedocs.org/en/latest/WSGIquickstart.html On Tue, Oct 27, 2015 at 8:29 PM, Corey Boyle wrote: > I gave waitress a try today and it seems to work great at first. > However, I'm now noticing that I am "in-consistently" having issues > with my CSRF token and occasionally getting logged out of the web app. > I suspect this has something to do with how the cookies are getting > handled. > > Has anyone else had this type of trouble with waitress? > > On Mon, Oct 26, 2015 at 1:59 PM, tigernassau > wrote: > > Had way too much trouble with uwsgi - found Waitress - a pure wsgi server > > this site showed how easy it is to use with Flask > > http://gr33ndata.blogspot.com/2012/01/waitress-flask.html > > > > > > > > Simple - in 2 minutes had Flask deployed with a simple systemd script to > run > > python3 app.py > > > > -- > > Tiger Nassau, Inc. > > www.tigernassau.com > > > > _______________________________________________ > > 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 matt at mattshields.org Wed Oct 28 09:27:27 2015 From: matt at mattshields.org (Matt Shields) Date: Wed, 28 Oct 2015 09:27:27 -0400 Subject: [Flask] Deploying Flask Solved With Waitress In-Reply-To: References: <562E69F5.80500@gmail.com> Message-ID: Have you tried gunicorn? Matt On Wed, Oct 28, 2015 at 9:16 AM, Dorian Hoxha wrote: > What trouble did you have with uwsgi? Did you read this page: > https://uwsgi-docs.readthedocs.org/en/latest/WSGIquickstart.html > > On Tue, Oct 27, 2015 at 8:29 PM, Corey Boyle wrote: > >> I gave waitress a try today and it seems to work great at first. >> However, I'm now noticing that I am "in-consistently" having issues >> with my CSRF token and occasionally getting logged out of the web app. >> I suspect this has something to do with how the cookies are getting >> handled. >> >> Has anyone else had this type of trouble with waitress? >> >> On Mon, Oct 26, 2015 at 1:59 PM, tigernassau >> wrote: >> > Had way too much trouble with uwsgi - found Waitress - a pure wsgi >> server >> > this site showed how easy it is to use with Flask >> > http://gr33ndata.blogspot.com/2012/01/waitress-flask.html >> > >> > >> > >> > Simple - in 2 minutes had Flask deployed with a simple systemd script >> to run >> > python3 app.py >> > >> > -- >> > Tiger Nassau, Inc. >> > www.tigernassau.com >> > >> > _______________________________________________ >> > 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 >> > > > _______________________________________________ > Flask mailing list > Flask at python.org > https://mail.python.org/mailman/listinfo/flask > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From tigernassau at gmail.com Wed Oct 28 10:25:22 2015 From: tigernassau at gmail.com (tigernassau) Date: Wed, 28 Oct 2015 08:25:22 -0600 Subject: [Flask] Deploying Flask Solved With Waitress In-Reply-To: References: <562E69F5.80500@gmail.com> Message-ID: <5630DAD2.2020902@gmail.com> On 10/27/2015 01:29 PM, Corey Boyle wrote: > I gave waitress a try today and it seems to work great at first. > However, I'm now noticing that I am "in-consistently" having issues > with my CSRF token and occasionally getting logged out of the web app. > I suspect this has something to do with how the cookies are getting handled. > assuming you have found a problem, then you should be posting it as an issue on the waitress github along with whatever tests and stack details From tigernassau at gmail.com Wed Oct 28 10:45:22 2015 From: tigernassau at gmail.com (tigernassau) Date: Wed, 28 Oct 2015 08:45:22 -0600 Subject: [Flask] Deploying Flask Solved With Waitress In-Reply-To: References: <562E69F5.80500@gmail.com> Message-ID: <5630DF82.6050606@gmail.com> On 10/28/2015 07:27 AM, Matt Shields wrote: > Have you tried gunicorn? some reading showed gunicorn should not be used in lieu of uwsgi - something to do with threading > > Matt > > On Wed, Oct 28, 2015 at 9:16 AM, Dorian Hoxha > wrote: > > What trouble did you have with uwsgi? Did you read this page: > https://uwsgi-docs.readthedocs.org/en/latest/WSGIquickstart.html > > On Tue, Oct 27, 2015 at 8:29 PM, Corey Boyle > wrote: > > I gave waitress a try today and it seems to work great at first. > However, I'm now noticing that I am "in-consistently" having > issues > with my CSRF token and occasionally getting logged out of the > web app. > I suspect this has something to do with how the cookies are > getting handled. > > Has anyone else had this type of trouble with waitress? > > On Mon, Oct 26, 2015 at 1:59 PM, tigernassau > > wrote: > > Had way too much trouble with uwsgi - found Waitress - a > pure wsgi server > > this site showed how easy it is to use with Flask > > http://gr33ndata.blogspot.com/2012/01/waitress-flask.html > > > > > > > > Simple - in 2 minutes had Flask deployed with a simple > systemd script to run > > python3 app.py > > > > -- > > Tiger Nassau, Inc. > > www.tigernassau.com > > > > _______________________________________________ > > 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 > > > > _______________________________________________ > 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 -- Tiger Nassau, Inc. www.tigernassau.com -------------- next part -------------- An HTML attachment was scrubbed... URL: From tigernassau at gmail.com Wed Oct 28 10:55:33 2015 From: tigernassau at gmail.com (tigernassau) Date: Wed, 28 Oct 2015 08:55:33 -0600 Subject: [Flask] Deploying Flask Solved With Waitress In-Reply-To: References: <562E69F5.80500@gmail.com> Message-ID: <5630E1E5.6060000@gmail.com> On 10/28/2015 07:16 AM, Dorian Hoxha wrote: > What trouble did you have with uwsgi? Did you read this page: > https://uwsgi-docs.readthedocs.org/en/latest/WSGIquickstart.html we actually could run flask w/ uwsgi from the command line - could not run it from systemd - so, some probably simple setup or permission issue but we couldn't see / solve the problem from the logs - posted this in this forum but didn't get any working response - wasted too many days trying to solve so had to move on. uwsgi docs don't show a systemd example under Flask and sorry we couldn't contribute a working one. > > On Tue, Oct 27, 2015 at 8:29 PM, Corey Boyle > wrote: > > I gave waitress a try today and it seems to work great at first. > However, I'm now noticing that I am "in-consistently" having issues > with my CSRF token and occasionally getting logged out of the web app. > I suspect this has something to do with how the cookies are > getting handled. > > Has anyone else had this type of trouble with waitress? > > On Mon, Oct 26, 2015 at 1:59 PM, tigernassau > > wrote: > > Had way too much trouble with uwsgi - found Waitress - a pure > wsgi server > > this site showed how easy it is to use with Flask > > http://gr33ndata.blogspot.com/2012/01/waitress-flask.html > > > > > > > > Simple - in 2 minutes had Flask deployed with a simple systemd > script to run > > python3 app.py > > > > -- > > Tiger Nassau, Inc. > > www.tigernassau.com > > > > _______________________________________________ > > 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 > > -- Tiger Nassau, Inc. www.tigernassau.com -------------- next part -------------- An HTML attachment was scrubbed... URL: From dorian.hoxha at gmail.com Wed Oct 28 19:13:05 2015 From: dorian.hoxha at gmail.com (Dorian Hoxha) Date: Thu, 29 Oct 2015 00:13:05 +0100 Subject: [Flask] Deploying Flask Solved With Waitress In-Reply-To: <5630E1E5.6060000@gmail.com> References: <562E69F5.80500@gmail.com> <5630E1E5.6060000@gmail.com> Message-ID: You should post to uwsgi mailing list. On Wed, Oct 28, 2015 at 3:55 PM, tigernassau wrote: > On 10/28/2015 07:16 AM, Dorian Hoxha wrote: > > What trouble did you have with uwsgi? Did you read this page: > https://uwsgi-docs.readthedocs.org/en/latest/WSGIquickstart.html > > > we actually could run flask w/ uwsgi from the command line - could not run > it from systemd - so, some probably simple setup or permission issue but we > couldn't see / solve the problem from the logs - posted this in this forum > but didn't get any working response - wasted too many days trying to solve > so had to move on. uwsgi docs don't show a systemd example under Flask > and sorry we couldn't contribute a working one. > > > > On Tue, Oct 27, 2015 at 8:29 PM, Corey Boyle wrote: > >> I gave waitress a try today and it seems to work great at first. >> However, I'm now noticing that I am "in-consistently" having issues >> with my CSRF token and occasionally getting logged out of the web app. >> I suspect this has something to do with how the cookies are getting >> handled. >> >> Has anyone else had this type of trouble with waitress? >> >> On Mon, Oct 26, 2015 at 1:59 PM, tigernassau < >> tigernassau at gmail.com> wrote: >> > Had way too much trouble with uwsgi - found Waitress - a pure wsgi >> server >> > this site showed how easy it is to use with Flask >> > http://gr33ndata.blogspot.com/2012/01/waitress-flask.html >> > >> > >> > >> > Simple - in 2 minutes had Flask deployed with a simple systemd script >> to run >> > python3 app.py >> > >> > -- >> > Tiger Nassau, Inc. >> > www.tigernassau.com >> > >> > _______________________________________________ >> > 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 >> > > > > -- > Tiger Nassau, Inc.www.tigernassau.com > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From badveli_vishnuus at yahoo.com Fri Oct 30 13:52:36 2015 From: badveli_vishnuus at yahoo.com (Vishnu) Date: Fri, 30 Oct 2015 10:52:36 -0700 Subject: [Flask] Rest server Message-ID: Hello All My intention is using flask only as a rest server, clients issues rest request to get Json data that is very huge, I need to implement using route, initially client asks how many records he wants, based on this I will read the whole Json data in a file and send only so many objects and return a Json response on how many total requests the client needs to make and the current request number, client will further make more rest requests with remaining request numbers, could you please provide a python code for server implementation? The Json data is in a file and huge, how do we make sure server opens the file and skip so many objects that are already read and continue from there based on the client request numbers with some Python code to follow. Thanks in advance for help, Vishnu From tuxtimo at gmail.com Fri Oct 30 14:02:15 2015 From: tuxtimo at gmail.com (Timo Furrer) Date: Fri, 30 Oct 2015 11:02:15 -0700 Subject: [Flask] Rest server In-Reply-To: References: Message-ID: Hi, As far as I know this is actually the developer mailing list for flask. The better option is to ask your question on Stack Overflow or similar sites. There you will benefit from a lot more users, too. And btw. just asking for a whole code solution for your project is a bad idea! Try it by yourself and ask specific questions on Stack Overflow if you need any help. Cheers On Fri, Oct 30, 2015 at 10:52 AM, Vishnu via Flask wrote: > > Hello All > My intention is using flask only as a rest server, clients issues rest > request to get > Json data that is very huge, I need to implement using route, initially > client asks how many records he wants, based on this I will read the whole > Json data in a file and send only so many objects and return a Json > response on how many total requests the client needs to make and the > current request number, client will further make more rest requests with > remaining request numbers, could you please provide a python code for > server implementation? The Json data is in a file and huge, how do we make > sure server opens the file and skip so many objects that are already read > and continue from there based on the client request numbers with some > Python code to follow. > Thanks in advance for help, > Vishnu > _______________________________________________ > Flask mailing list > Flask at python.org > https://mail.python.org/mailman/listinfo/flask > -- Mit freundlichen Gr?ssen Timo Furrer https://github.com/timofurrer tuxtimo at gmail.com -------------- next part -------------- An HTML attachment was scrubbed... URL: From dmarv at dop.com Fri Oct 30 14:13:23 2015 From: dmarv at dop.com (Dale Marvin) Date: Fri, 30 Oct 2015 11:13:23 -0700 Subject: [Flask] Rest server In-Reply-To: References: Message-ID: <5633B343.6050501@dop.com> I recommend you read Miguel Grinberg's Flask tutorials. For starters: I recently subscriber to this list, is it customary to top post? -Dale On 10/30/15 11:02 AM, Timo Furrer wrote: > Hi, > > As far as I know this is actually the developer mailing list for flask. > The better option is to ask your question on Stack Overflow or similar > sites. There you will benefit from a lot more users, too. > And btw. just asking for a whole code solution for your project is a bad > idea! Try it by yourself and ask specific questions on Stack Overflow if > you need any help. > > Cheers > > On Fri, Oct 30, 2015 at 10:52 AM, Vishnu via Flask > wrote: > > > Hello All > My intention is using flask only as a rest server, clients issues > rest request to get > Json data that is very huge, I need to implement using route, > initially client asks how many records he wants, based on this I > will read the whole Json data in a file and send only so many > objects and return a Json response on how many total requests the > client needs to make and the current request number, client will > further make more rest requests with remaining request numbers, > could you please provide a python code for server implementation? > The Json data is in a file and huge, how do we make sure server > opens the file and skip so many objects that are already read and > continue from there based on the client request numbers with some > Python code to follow. > Thanks in advance for help, > Vishnu > _______________________________________________ > Flask mailing list > Flask at python.org > https://mail.python.org/mailman/listinfo/flask > > > > > -- > Mit freundlichen Gr?ssen > > Timo Furrer > https://github.com/timofurrer > tuxtimo at gmail.com > > > _______________________________________________ > Flask mailing list > Flask at python.org > https://mail.python.org/mailman/listinfo/flask >