From 451517996 at qq.com Sun May 1 09:39:35 2016 From: 451517996 at qq.com (=?gb18030?B?zuLD+g==?=) Date: Sun, 1 May 2016 21:39:35 +0800 Subject: [Flask] Flask Digest, Vol 10, Issue 45 In-Reply-To: References: Message-ID: btw github:https://github.com/qianqians/abelkhan.git ------------------ Original ------------------ From: "flask-request"; Date: 2016?4?29?(???) ??0:00 To: "flask"; Subject: Flask Digest, Vol 10, Issue 45 Send Flask mailing list submissions to flask at python.org To subscribe or unsubscribe via the World Wide Web, visit https://mail.python.org/mailman/listinfo/flask or, via email, send a message with subject or body 'help' to flask-request at python.org You can reach the person managing the list at flask-owner at python.org When replying, please edit your Subject line so it is more specific than "Re: Contents of Flask digest..." Today's Topics: 1. Need advice in implementing news feed in flask (aiman parvaiz) ---------------------------------------------------------------------- Message: 1 Date: Thu, 28 Apr 2016 11:45:54 +0530 From: aiman parvaiz To: flask at python.org Subject: [Flask] Need advice in implementing news feed in flask Message-ID: Content-Type: text/plain; charset="utf-8" Hi all, I am new to Python and am working on writing backend (REST API using Flask) for a Android app (Simple content posting app). I need advice in implementing a notification feed where a user can see all the activities related to their posts, for example: if some one commented on user's post it should show up on this feed. Also, there are some activities in this feed for which we need to show notification even if the user is not using the app (similar to push notification). I am new to Python and understand that a part of this can be achieved by Push notifications(GCM) but what should be the logic for showing events in feed which are not a part of push notification. I hope I was able to explain myself. Thanks -------------- next part -------------- An HTML attachment was scrubbed... URL: <" target="_blank">http://mail.python.org/pipermail/flask/attachments/20160428/5aff955d/attachment-0001.html>; ------------------------------ Subject: Digest Footer _______________________________________________ Flask mailing list Flask at python.org https://mail.python.org/mailman/listinfo/flask ------------------------------ End of Flask Digest, Vol 10, Issue 45 ************************************* -------------- next part -------------- An HTML attachment was scrubbed... URL: From 451517996 at qq.com Sun May 1 09:39:04 2016 From: 451517996 at qq.com (=?gb18030?B?zuLD+g==?=) Date: Sun, 1 May 2016 21:39:04 +0800 Subject: [Flask] Flask Digest, Vol 10, Issue 45 In-Reply-To: References: Message-ID: http://abelkhan.com/user/?uid=5710fbe6438fcb0e7c178cbe build a open source twitter by flask now it is a demo reception every one join my repository ------------------ Original ------------------ From: "flask-request"; Date: 2016?4?29?(???) ??0:00 To: "flask"; Subject: Flask Digest, Vol 10, Issue 45 Send Flask mailing list submissions to flask at python.org To subscribe or unsubscribe via the World Wide Web, visit https://mail.python.org/mailman/listinfo/flask or, via email, send a message with subject or body 'help' to flask-request at python.org You can reach the person managing the list at flask-owner at python.org When replying, please edit your Subject line so it is more specific than "Re: Contents of Flask digest..." Today's Topics: 1. Need advice in implementing news feed in flask (aiman parvaiz) ---------------------------------------------------------------------- Message: 1 Date: Thu, 28 Apr 2016 11:45:54 +0530 From: aiman parvaiz To: flask at python.org Subject: [Flask] Need advice in implementing news feed in flask Message-ID: Content-Type: text/plain; charset="utf-8" Hi all, I am new to Python and am working on writing backend (REST API using Flask) for a Android app (Simple content posting app). I need advice in implementing a notification feed where a user can see all the activities related to their posts, for example: if some one commented on user's post it should show up on this feed. Also, there are some activities in this feed for which we need to show notification even if the user is not using the app (similar to push notification). I am new to Python and understand that a part of this can be achieved by Push notifications(GCM) but what should be the logic for showing events in feed which are not a part of push notification. I hope I was able to explain myself. Thanks -------------- next part -------------- An HTML attachment was scrubbed... URL: <" target="_blank">http://mail.python.org/pipermail/flask/attachments/20160428/5aff955d/attachment-0001.html>; ------------------------------ Subject: Digest Footer _______________________________________________ Flask mailing list Flask at python.org https://mail.python.org/mailman/listinfo/flask ------------------------------ End of Flask Digest, Vol 10, Issue 45 ************************************* -------------- next part -------------- An HTML attachment was scrubbed... URL: From colin at techdata.net.au Mon May 2 00:24:39 2016 From: colin at techdata.net.au (Colin Haig) Date: Mon, 02 May 2016 12:24:39 +0800 Subject: [Flask] Sessions Message-ID: Hi I have a flask app running on apache(windows 7) - mod_wsgi - when I go to the app from one machine and set a variable and then go to the app from another computer and reset the variable it effects the first machines variable. It seems that the app/apache are not running in separate threads/processes. I have set processes app.run(processes=10) Any help greatly appreciated. Regards Colin -------------- next part -------------- An HTML attachment was scrubbed... URL: From and.damore at gmail.com Mon May 2 02:48:10 2016 From: and.damore at gmail.com (Andrea D'Amore) Date: Mon, 2 May 2016 08:48:10 +0200 Subject: [Flask] Sessions In-Reply-To: References: Message-ID: On 2 May 2016 at 06:24, Colin Haig wrote: > when I go to the app from one machine and set a variable and then go to the > app from another computer and reset the variable Can you provide an reproducible example or a more detailed description of the steps involved in "going to another machine and resetting a variable"? -- Andrea From ahall at autodist.com Tue May 3 16:05:54 2016 From: ahall at autodist.com (Alex Hall) Date: Tue, 3 May 2016 16:05:54 -0400 Subject: [Flask] Deploying Flask on Debian Message-ID: Hello list, My work has a Google Cloud account, so my boss just made me a Debian server. Being virtual, I can't physically access it, but I've got SSH and SCP, so same thing. No remote GUI, though, just command line. I've been looking up how to deploy Flask on Linux, Debian specifically, for a couple hours. I'm getting a *lot* of hits, but nothing that seems to be in line with anything else. Some tell me to use WSGI (which I expected), but others say mod_wsgi, and others UWSGI. Mod_wsgi might mean, some say, compiling it for Python3, but I'm on Python 2.7.9? Most assume I'm using a virtual environment, which I'm not, because Python and other web projects are the only things on this server. The Flask docs talk about UWSGI, then something called MGinx? I'm using Apache2, again on Debian 8. Is there a single tutorial or article that most people recommend? I'm not very experienced with Debian, but I'm fine with a command line interface in general. I've got Flask, Flask-WTF, and the pyodbc module I'll need, and now just want to get Flask running with Apache2 so Apache can serve my Flask app. Thanks. -- Alex Hall Automatic Distributors, IT department ahall at autodist.com -------------- next part -------------- An HTML attachment was scrubbed... URL: From ford.anthonyj at gmail.com Tue May 3 16:19:03 2016 From: ford.anthonyj at gmail.com (Anthony Ford) Date: Tue, 3 May 2016 15:19:03 -0500 Subject: [Flask] Deploying Flask on Debian In-Reply-To: References: Message-ID: Personally, I really like the Digital Ocean guides. You can check out the Ubuntu guide, as it shouldn't be all that different from Debian (I used it as a template for internal deploy docs I wrote at my last position). https://www.digitalocean.com/community/tutorials/how-to-serve-flask-applications-with-uwsgi-and-nginx-on-ubuntu-14-04 I personally prefer uwsgi behind Nginx Anthony Ford, KF5IBN, ford.anthonyj at gmail.com On Tue, May 3, 2016 at 3:05 PM, Alex Hall wrote: > Hello list, > My work has a Google Cloud account, so my boss just made me a Debian > server. Being virtual, I can't physically access it, but I've got SSH and > SCP, so same thing. No remote GUI, though, just command line. > > I've been looking up how to deploy Flask on Linux, Debian specifically, > for a couple hours. I'm getting a *lot* of hits, but nothing that seems to > be in line with anything else. Some tell me to use WSGI (which I expected), > but others say mod_wsgi, and others UWSGI. Mod_wsgi might mean, some say, > compiling it for Python3, but I'm on Python 2.7.9? Most assume I'm using a > virtual environment, which I'm not, because Python and other web projects > are the only things on this server. The Flask docs talk about UWSGI, then > something called MGinx? I'm using Apache2, again on Debian 8. > > Is there a single tutorial or article that most people recommend? I'm not > very experienced with Debian, but I'm fine with a command line interface in > general. I've got Flask, Flask-WTF, and the pyodbc module I'll need, and > now just want to get Flask running with Apache2 so Apache can serve my > Flask app. Thanks. > > -- > Alex Hall > Automatic Distributors, IT department > ahall at autodist.com > > _______________________________________________ > Flask mailing list > Flask at python.org > https://mail.python.org/mailman/listinfo/flask > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From ahall at autodist.com Tue May 3 18:02:00 2016 From: ahall at autodist.com (Alex Hall) Date: Tue, 3 May 2016 18:02:00 -0400 Subject: [Flask] Deploying Flask on Debian In-Reply-To: References: Message-ID: Thanks guys. I'm intrigued by Nginx, after reading more about it. The problem is that apt-get install nginx keeps failing, with some kind of dependency problem, sudo or no sudo. I've stopped Apache, but still get the error. Thus, I'd like to stick to Apache if I could, simply because it's already installed and (to my knowledge) working. This is a small, internal site that doesn't need the efficiency of Nginx to run, and I'm having enough problems with getting Flask to work that messing with installing a stubborn Nginx doesn't seem the best way to stay sane. :) I'd love to play with Nginx, as it seems easier to configure than Apache, but unless I can get it to install cleanly that's not really an option. On Tue, May 3, 2016 at 4:19 PM, Anthony Ford wrote: > Personally, I really like the Digital Ocean guides. > > You can check out the Ubuntu guide, as it shouldn't be all that different > from Debian (I used it as a template for internal deploy docs I wrote at my > last position). > > > https://www.digitalocean.com/community/tutorials/how-to-serve-flask-applications-with-uwsgi-and-nginx-on-ubuntu-14-04 > > I personally prefer uwsgi behind Nginx > > > Anthony Ford, > KF5IBN, > ford.anthonyj at gmail.com > > On Tue, May 3, 2016 at 3:05 PM, Alex Hall wrote: > >> Hello list, >> My work has a Google Cloud account, so my boss just made me a Debian >> server. Being virtual, I can't physically access it, but I've got SSH and >> SCP, so same thing. No remote GUI, though, just command line. >> >> I've been looking up how to deploy Flask on Linux, Debian specifically, >> for a couple hours. I'm getting a *lot* of hits, but nothing that seems to >> be in line with anything else. Some tell me to use WSGI (which I expected), >> but others say mod_wsgi, and others UWSGI. Mod_wsgi might mean, some say, >> compiling it for Python3, but I'm on Python 2.7.9? Most assume I'm using a >> virtual environment, which I'm not, because Python and other web projects >> are the only things on this server. The Flask docs talk about UWSGI, then >> something called MGinx? I'm using Apache2, again on Debian 8. >> >> Is there a single tutorial or article that most people recommend? I'm not >> very experienced with Debian, but I'm fine with a command line interface in >> general. I've got Flask, Flask-WTF, and the pyodbc module I'll need, and >> now just want to get Flask running with Apache2 so Apache can serve my >> Flask app. Thanks. >> >> -- >> Alex Hall >> Automatic Distributors, IT department >> ahall at autodist.com >> >> _______________________________________________ >> Flask mailing list >> Flask at python.org >> https://mail.python.org/mailman/listinfo/flask >> >> > -- Alex Hall Automatic Distributors, IT department ahall at autodist.com -------------- next part -------------- An HTML attachment was scrubbed... URL: From and.damore at gmail.com Wed May 4 03:44:55 2016 From: and.damore at gmail.com (Andrea D'Amore) Date: Wed, 4 May 2016 09:44:55 +0200 Subject: [Flask] Deploying Flask on Debian In-Reply-To: References: Message-ID: On 4 May 2016 at 00:02, Alex Hall wrote: > Thanks guys. I'm intrigued by Nginx, after reading more about it. The > problem is that apt-get install nginx keeps failing, with some kind of > dependency problem, sudo or no sudo. That's odd for a freshly installed Jessie, it could be a clash with the installed apache service but since you didn't paste the actual APT error there's no way to tell. > I've stopped Apache, but still get the > error. Thus, I'd like to stick to Apache if I could, simply because it's > already installed and (to my knowledge) working. I stay away from apache httpd as much as I can, for a similar need I use lighttpd as proxy to the flask application on localhost. > This is a small, internal > site that doesn't need the efficiency of Nginx to run, and I'm having enough > problems with getting Flask to work that messing with installing a stubborn > Nginx doesn't seem the best way to stay sane. uwsgi is capable of directly serving the app, if it's a LAN app you're probably fine deploying the app with it, for a very low number of clients you could even use the builtin server. Just the other day I was reading again about flask deployment and I think I saw numbers as rule of thumb, 10 clients for builtin server and 100 for uwsgi IIRC but I may as well just making those up. If you decide to go with uwsgi, that I'd suggest in this case, just follow its documentation, it's detailed and got plenty of examples. If you want another process to serve TCP 80 remember to shut down the apache service. -- Andrea From and.damore at gmail.com Wed May 4 03:52:47 2016 From: and.damore at gmail.com (Andrea D'Amore) Date: Wed, 4 May 2016 09:52:47 +0200 Subject: [Flask] Deploying Flask on Debian In-Reply-To: References: Message-ID: On 3 May 2016 at 22:05, Alex Hall wrote: > Most assume I'm using a virtual environment, which I'm not, because Python > and other web projects are the only things on this server. About this, python packages in Debian are often outdated, and some of the more esoteric ones aren't in repo at all. I'd use a dedicated environment for the app anyway if you plan to upgrade the packages along the way or in a way that isn't tied to debian's packages update cycle. -- Andrea From davidnieder at gmx.de Wed May 4 06:41:54 2016 From: davidnieder at gmx.de (David Nieder) Date: Wed, 4 May 2016 12:41:54 +0200 Subject: [Flask] Deploying Flask on Debian In-Reply-To: References: Message-ID: <095f0347-440f-aadf-187e-2167937e91a7@gmx.de> Sorry for the second mail, Alex. I didn't reply to the list the first time. On 03.05.2016 22:05, Alex Hall wrote: > Hello list, > My work has a Google Cloud account, so my boss just made me a Debian > server. Being virtual, I can't physically access it, but I've got SSH and > SCP, so same thing. No remote GUI, though, just command line. > > I've been looking up how to deploy Flask on Linux, Debian specifically, for > a couple hours. I'm getting a *lot* of hits, but nothing that seems to be > in line with anything else. Some tell me to use WSGI (which I expected), > but others say mod_wsgi, and others UWSGI. Mod_wsgi might mean, some say, > compiling it for Python3, but I'm on Python 2.7.9? Most assume I'm using a > virtual environment, which I'm not, because Python and other web projects > are the only things on this server. The Flask docs talk about UWSGI, then > something called MGinx? I'm using Apache2, again on Debian 8. > > Is there a single tutorial or article that most people recommend? I'm not > very experienced with Debian, but I'm fine with a command line interface in > general. I've got Flask, Flask-WTF, and the pyodbc module I'll need, and > now just want to get Flask running with Apache2 so Apache can serve my > Flask app. Thanks. > Hello Alex I'm using Apache and mod_wsgi for some years now without any bigger problems. There is a section in the flask docs: http://flask.pocoo.org/docs/0.10/deploying/mod_wsgi/ Altough the Apache configuration changed a bit with 2.4, which is the version that comes with Debian 8. If you search for "debian 8 mod_wsgi" or "debian mod_wsgi flask" you will find a lot of guides (deploying a django app is very similar to a flask app and ubuntu is similar to debian) For a basic configuration you just need two things. A wsgi-file that imports you flask app and a WSGIScriptAlias directive in your apache/vhost config. Chances are it won't work on your first try so keep an eye on the apache error logs which should by in /var/log/apache2 I also would recommend using virtualenv but you can start without. Good luck ;) David > > > _______________________________________________ > Flask mailing list > Flask at python.org > https://mail.python.org/mailman/listinfo/flask > From ahall at autodist.com Wed May 4 08:42:38 2016 From: ahall at autodist.com (Alex Hall) Date: Wed, 4 May 2016 08:42:38 -0400 Subject: [Flask] Deploying Flask on Debian In-Reply-To: <095f0347-440f-aadf-187e-2167937e91a7@gmx.de> References: <095f0347-440f-aadf-187e-2167937e91a7@gmx.de> Message-ID: Thanks for the help thus far, everyone. Just a quick update to say that I got Nginx installed on Jessie. The problem was that, though I'd killed Apache2, it hadn't stopped. I stopped it again, and this time the Nginx installation went smoothly. I still see the Apache index page, but I suspect that's because Nginx is looking in /var/www and just serving the index.html file it finds, which is the Apache file. Anyway, since that works and people here seem to prefer Nginx, I'll try to use Flask with Nginx first before reverting to Apache should I fail. Back to the Digital Oceans tutorial I go. On Wed, May 4, 2016 at 6:41 AM, David Nieder wrote: > Sorry for the second mail, Alex. I didn't reply to the list the first time. > > On 03.05.2016 22:05, Alex Hall wrote: > >> Hello list, >> My work has a Google Cloud account, so my boss just made me a Debian >> server. Being virtual, I can't physically access it, but I've got SSH and >> SCP, so same thing. No remote GUI, though, just command line. >> >> I've been looking up how to deploy Flask on Linux, Debian specifically, >> for >> a couple hours. I'm getting a *lot* of hits, but nothing that seems to be >> in line with anything else. Some tell me to use WSGI (which I expected), >> but others say mod_wsgi, and others UWSGI. Mod_wsgi might mean, some say, >> compiling it for Python3, but I'm on Python 2.7.9? Most assume I'm using a >> virtual environment, which I'm not, because Python and other web projects >> are the only things on this server. The Flask docs talk about UWSGI, then >> something called MGinx? I'm using Apache2, again on Debian 8. >> >> Is there a single tutorial or article that most people recommend? I'm not >> very experienced with Debian, but I'm fine with a command line interface >> in >> general. I've got Flask, Flask-WTF, and the pyodbc module I'll need, and >> now just want to get Flask running with Apache2 so Apache can serve my >> Flask app. Thanks. >> >> > Hello Alex > I'm using Apache and mod_wsgi for some years now without any bigger > problems. There is a section in the flask docs: > http://flask.pocoo.org/docs/0.10/deploying/mod_wsgi/ > > Altough the Apache configuration changed a bit with 2.4, which is the > version that comes with Debian 8. > > If you search for "debian 8 mod_wsgi" or "debian mod_wsgi flask" you > will find a lot of guides (deploying a django app is very similar to a > flask app and ubuntu is similar to debian) > > For a basic configuration you just need two things. A wsgi-file that > imports you flask app and a WSGIScriptAlias directive in your > apache/vhost config. > > Chances are it won't work on your first try so keep an eye on the apache > error logs which should by in /var/log/apache2 > > I also would recommend using virtualenv but you can start without. > > > Good luck ;) > David > > >> >> _______________________________________________ >> 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 > -- Alex Hall Automatic Distributors, IT department ahall at autodist.com -------------- next part -------------- An HTML attachment was scrubbed... URL: From ahall at autodist.com Wed May 4 09:06:20 2016 From: ahall at autodist.com (Alex Hall) Date: Wed, 4 May 2016 09:06:20 -0400 Subject: [Flask] slightly OT: packaging/moving flask app with virtualenv Message-ID: Hey list, At the urging of several members here, I'll give virtualenv a shot while I'm installing and moving everything. Currently, I have my Flask app working. It's small--just a couple pages with a bunch of JS--but does need Pyodbc and WTF to work. Is there a way I can take my existing app, put it into a virtual environment, and toss the whole thing on my Debian server? I've installed virtualenv on the server already, as well as UWSGI. Is this doable, or should I upload the entire directory and somehow put it into a virtual environment on the server? Am I too late--that is, can this only be done when you start a new project? -- Alex Hall Automatic Distributors, IT department ahall at autodist.com -------------- next part -------------- An HTML attachment was scrubbed... URL: From coreybrett at gmail.com Wed May 4 10:07:28 2016 From: coreybrett at gmail.com (Corey Boyle) Date: Wed, 4 May 2016 10:07:28 -0400 Subject: [Flask] slightly OT: packaging/moving flask app with virtualenv In-Reply-To: References: Message-ID: Virtualenv works by temporarily changing the active PATH so that your scripts see an alternate (and isolated) Python interpreter and libraries instead of seeing the globally installed ones. So... I don't think it would ever be to late to start using a virtualenv. Perhaps the only thing that could be effected is the paths of your import statements. Basically, you need to setup a virtualenv on the server, that matches the virtualenv on your dev box, and tell Apache to use it when executing your Python scripts. (I've never used Apache with Python, so I can't help with that part.) I also like using virtualenvwrapper, but I'm not sure if that would help or hurt you at this point. On debian... apt install python-virtualenv apt install virtualenvwrapper What OS are you using for development? On Wed, May 4, 2016 at 9:06 AM, Alex Hall wrote: > Hey list, > At the urging of several members here, I'll give virtualenv a shot while I'm > installing and moving everything. Currently, I have my Flask app working. > It's small--just a couple pages with a bunch of JS--but does need Pyodbc and > WTF to work. Is there a way I can take my existing app, put it into a > virtual environment, and toss the whole thing on my Debian server? I've > installed virtualenv on the server already, as well as UWSGI. Is this > doable, or should I upload the entire directory and somehow put it into a > virtual environment on the server? Am I too late--that is, can this only be > done when you start a new project? > > -- > Alex Hall > Automatic Distributors, IT department > ahall at autodist.com > > _______________________________________________ > Flask mailing list > Flask at python.org > https://mail.python.org/mailman/listinfo/flask > From ahall at autodist.com Wed May 4 10:49:11 2016 From: ahall at autodist.com (Alex Hall) Date: Wed, 4 May 2016 10:49:11 -0400 Subject: [Flask] slightly OT: packaging/moving flask app with virtualenv In-Reply-To: References: Message-ID: I've been doing some reading and tests on this. I've gotten things to work locally inside a virtual environment, including the all-important database communication, so we're looking good there. The docs say, though, that environments can't be moved between platforms; making this extra fun is that I'm developing on Windows and wanting to serve files from Debian. I suppose my next step is to get an environment set up on the Debian server and make sure it works from there. Once it does, Nginx and UWSGI will be brought into the mix. As I understand it, I'd want to copy my entire project directory from my Windows machine over to the server, probably in /var/www/mySite. I'd then cd into /var/www, run virtualenv mySite, activate the new environment, install my packages, and I should be set? Again, this isn't touching serving for now, just getting my project to run. Fortunately, it doesn't use hard-coded paths, output files, or anything else. I use {{url_for()}} for all my links and script/style includes, and I never rely on Windows-only libraries. This should be reasonably easy, assuming I have the general process correct. On Wed, May 4, 2016 at 10:07 AM, Corey Boyle wrote: > Virtualenv works by temporarily changing the active PATH so that your > scripts see an alternate (and isolated) Python interpreter and > libraries instead of seeing the globally installed ones. > > So... I don't think it would ever be to late to start using a virtualenv. > Perhaps the only thing that could be effected is the paths of your > import statements. > > Basically, you need to setup a virtualenv on the server, that matches > the virtualenv on your dev box, and tell Apache to use it when > executing your Python scripts. (I've never used Apache with Python, so > I can't help with that part.) > > I also like using virtualenvwrapper, but I'm not sure if that would > help or hurt you at this point. > > On debian... > apt install python-virtualenv > apt install virtualenvwrapper > > What OS are you using for development? > > On Wed, May 4, 2016 at 9:06 AM, Alex Hall wrote: > > Hey list, > > At the urging of several members here, I'll give virtualenv a shot while > I'm > > installing and moving everything. Currently, I have my Flask app working. > > It's small--just a couple pages with a bunch of JS--but does need Pyodbc > and > > WTF to work. Is there a way I can take my existing app, put it into a > > virtual environment, and toss the whole thing on my Debian server? I've > > installed virtualenv on the server already, as well as UWSGI. Is this > > doable, or should I upload the entire directory and somehow put it into a > > virtual environment on the server? Am I too late--that is, can this only > be > > done when you start a new project? > > > > -- > > Alex Hall > > Automatic Distributors, IT department > > ahall at autodist.com > > > > _______________________________________________ > > Flask mailing list > > Flask at python.org > > https://mail.python.org/mailman/listinfo/flask > > > -- Alex Hall Automatic Distributors, IT department ahall at autodist.com -------------- next part -------------- An HTML attachment was scrubbed... URL: From Adam.Steer at anu.edu.au Tue May 3 16:33:25 2016 From: Adam.Steer at anu.edu.au (Adam Steer) Date: Tue, 3 May 2016 20:33:25 +0000 Subject: [Flask] Deploying Flask on Debian In-Reply-To: References: Message-ID: <4E066FD5-E4B6-4EE1-B5C7-7E5F53FD0805@anu.edu.au> Hi Alex (noting also Anthony?s quick response) I?ve just jumped through this same set of hoops, going from ?no idea? to ?flask = deployed on WSGI?, on ubuntu (nearly debian) and CentOS. After the fact, these docs make sense: http://flask.pocoo.org/docs/0.10/deploying/mod_wsgi/ ?but starting out I was completely at a loss about where to start. I think the Flask docs assume you just try it, and see :) So the examples are sometimes reliant on the developer either already knowing a bunch, or trying things and learning by breaking things. Which is OK. I drew heavily on the deployment style here: https://www.digitalocean.com/community/tutorials/how-to-deploy-a-flask-application-on-an-ubuntu-vps and here: http://www.jakowicz.com/flask-apache-wsgi/ ?but i did find the process pretty confusing. When I get into the office I can send some documented flask/wsgi/apache config files if that would help. Just a quick note, it?s still helpful to use a virtual environment, because you never know when you might need to transport your app someplace else - and you can bundle up all the things your project needs. Cheers Adam > On 4 May 2016, at 6:05 AM, Alex Hall wrote: > > Hello list, > My work has a Google Cloud account, so my boss just made me a Debian server. Being virtual, I can't physically access it, but I've got SSH and SCP, so same thing. No remote GUI, though, just command line. > > I've been looking up how to deploy Flask on Linux, Debian specifically, for a couple hours. I'm getting a *lot* of hits, but nothing that seems to be in line with anything else. Some tell me to use WSGI (which I expected), but others say mod_wsgi, and others UWSGI. Mod_wsgi might mean, some say, compiling it for Python3, but I'm on Python 2.7.9? Most assume I'm using a virtual environment, which I'm not, because Python and other web projects are the only things on this server. The Flask docs talk about UWSGI, then something called MGinx? I'm using Apache2, again on Debian 8. > > Is there a single tutorial or article that most people recommend? I'm not very experienced with Debian, but I'm fine with a command line interface in general. I've got Flask, Flask-WTF, and the pyodbc module I'll need, and now just want to get Flask running with Apache2 so Apache can serve my Flask app. Thanks. > > -- > Alex Hall > Automatic Distributors, IT department > ahall at autodist.com > _______________________________________________ > Flask mailing list > Flask at python.org > https://mail.python.org/mailman/listinfo/flask From Stephen.Mazzei at asrcfederal.com Thu May 5 12:12:47 2016 From: Stephen.Mazzei at asrcfederal.com (Mazzei, Stephen Andrew) Date: Thu, 5 May 2016 16:12:47 +0000 Subject: [Flask] Code evaluation Message-ID: Good afternoon, I have been tasked with expanding an old php website to allow for additional databases. After my initial run through of this I decided it was just time for a complete redo of the environment. As I am not a web developer, I decided to try to move to a language I know a little more about and thus I found flask/python. I have about 80% of the website migrated using random methods and practices I have found online I was wondering if there is anyone who knows flask/python/mysqld pretty well and can assist me and taking a look at the code, telling me how I am doing wrong, how to make simple improvements so I can speed this process up. In my mind this is a pretty straight database to webpage application, with 90% of the entire page is just pulling the data and presenting it. We have a few sections under the "admin" pages to perform updates. --- Stephen A. Mazzei Systems Administrator | AFDS, ASRC Federal Data Solutions - P&G HPC Account | 513-634-9965 ________________________________ The preceding message (including attachments) is covered by the Electronic Communication Privacy Act, 18 U.S.C. sections 2510-2512, is intended only for the person or entity to which it is addressed, and may contain information that is confidential, protected by attorney-client or other privilege, or otherwise protected from disclosure by law. If you are not the intended recipient, you are hereby notified that any retention, dissemination, distribution, or copying of this communication is strictly prohibited. Please reply to the sender that you have received the message in error and destroy the original message and all copies. -------------- next part -------------- An HTML attachment was scrubbed... URL: From ahall at autodist.com Thu May 5 12:30:22 2016 From: ahall at autodist.com (Alex Hall) Date: Thu, 5 May 2016 12:30:22 -0400 Subject: [Flask] Deploying Flask on Debian In-Reply-To: References: Message-ID: Hey all, Here's where I am on this journey. I spent the last day or so stuck on getting my database and Debian server to talk. I FINALLY got that to work just now, and my Flask app is able to start up. It seems the Flask server can't serve to external web browsers, only those able to access localhost, but I'm trusting that the app will now work as expected. I've got Nginx installed and, it claims, starting up normally. I've installed WSGI and UWSGI, and my Flask app is in a virtual environment, which I can activate successfully. At last, I'm ready for the actual configuration of the pieces to let Nginx serve Flask. Which leads to a couple questions, for clarification. 1. Is Mod_WSGI only for Apache? Should I stick with UWSGI, given that I'm using Nginx? 2. I read that UWSGI is also a web server, and that it's suggested to use UWSGI with Nginx behind it. This seems more complicated than I expected. Did I understand it right? Is this a choice, or the only/best way to set things up? 3. When all this is up and running, will views be relative to my app, or app/templates? That is, should I set the document root in Nginx to be /var/www/myApp, or /var/www/myApp/templates? The myApp folder has run.py, config.py, static/, and templates/. On Wed, May 4, 2016 at 3:44 AM, Andrea D'Amore wrote: > On 4 May 2016 at 00:02, Alex Hall wrote: > > Thanks guys. I'm intrigued by Nginx, after reading more about it. The > > problem is that apt-get install nginx keeps failing, with some kind of > > dependency problem, sudo or no sudo. > > That's odd for a freshly installed Jessie, it could be a clash with > the installed apache service but since you didn't paste the actual APT > error there's no way to tell. > > > I've stopped Apache, but still get the > > error. Thus, I'd like to stick to Apache if I could, simply because it's > > already installed and (to my knowledge) working. > > I stay away from apache httpd as much as I can, for a similar need I > use lighttpd as proxy to the flask application on localhost. > > > This is a small, internal > > site that doesn't need the efficiency of Nginx to run, and I'm having > enough > > problems with getting Flask to work that messing with installing a > stubborn > > Nginx doesn't seem the best way to stay sane. > > uwsgi is capable of directly serving the app, if it's a LAN app you're > probably fine deploying the app with it, for a very low number of > clients you could even use the builtin server. > Just the other day I was reading again about flask deployment and I > think I saw numbers as rule of thumb, 10 clients for builtin server > and 100 for uwsgi IIRC but I may as well just making those up. > > If you decide to go with uwsgi, that I'd suggest in this case, just > follow its documentation, it's detailed and got plenty of examples. If > you want another process to serve TCP 80 remember to shut down the > apache service. > > > -- > Andrea > -- Alex Hall Automatic Distributors, IT department ahall at autodist.com -------------- next part -------------- An HTML attachment was scrubbed... URL: From ford.anthonyj at gmail.com Thu May 5 13:30:20 2016 From: ford.anthonyj at gmail.com (Anthony Ford) Date: Thu, 5 May 2016 12:30:20 -0500 Subject: [Flask] Deploying Flask on Debian In-Reply-To: References: Message-ID: Hey Alex, Congrats on the progress so far. Let me see if I can clarify some things for you 1. Is Mod_WSGI only for Apache? Should I stick with UWSGI, given that I'm > using Nginx? > Yes. Mod_WSGI is essentially a router that passes the request from Apache (the url requested, HTTP headers, etc), and will accept the response from your app and pass it back to Apache to send to the client. If you are using Nginx, yes you should stick with uWSGI. > 2. I read that UWSGI is also a web server, and that it's suggested to use > UWSGI with Nginx behind it. This seems more complicated than I expected. > Did I understand it right? Is this a choice, or the only/best way to set > things up? > uWSGI can act as a standalone web-server for HTTP/S ( http://uwsgi-docs.readthedocs.io/en/latest/HTTP.html#the-uwsgi-http-https-router). If you have a heavy site (i.e. hundreds+ of active users), you will waste efficiency and capacity by having uWSGI handle your static files (i.e. your JS, images, etc.), so it is recommended to hide uWSGI behind an HTTP server (i.e. Nginx) and let it handle the static loads since they are significantly better at serving static files. No, you do not have to do this if you are building an internal or low use site (but if the site is public, be prepared for traffic spikes that can bring your site down, like slash-doting or reddit hug-of-deaths). Use the `--http` option as suggesting in the above link. > 3. When all this is up and running, will views be relative to my app, or > app/templates? That is, should I set the document root in Nginx to be > /var/www/myApp, or /var/www/myApp/templates? The myApp folder has run.py, > config.py, static/, and templates/. If you are serving your app behind Nginx, the main document root (or location in nginx parlance), i.e. /, would be your app in wsgi (the uwsgi_pass section). The only thing Nginx should serve would be your static files in `static/` (which should be served as `/static/`. I've stuck together a gist with some sanitized config files from a recent project. You can find them here: https://gist.github.com/ajford/32ca09c1bdb67e2211247f189aa2ae9a It's got some complexity (the vars in the wsgi definitions) because this was running on an applications server with three different Flask based apps running behind Nginx. In my case, while the number of users was low (~10 max, more like a single user concurrent), I only had the one server available, so they were placed behind Nginx to handle the virtual server names (so the different apps wouldn't crash when serving). This may be possible using uwsgi stand-alone, but I already knew how to do it in Nginx. Hope this helps! Anthony Ford, KF5IBN, ford.anthonyj at gmail.com -------------- next part -------------- An HTML attachment was scrubbed... URL: From ahall at autodist.com Thu May 5 13:56:21 2016 From: ahall at autodist.com (Alex Hall) Date: Thu, 5 May 2016 13:56:21 -0400 Subject: [Flask] Deploying Flask on Debian In-Reply-To: References: Message-ID: Thanks for the answers! At the risk of going a bit off topic, I made my Nginx and UWSGI configuration files according to this guide: http://www.markjberger.com/flask-with-virtualenv-uwsgi-nginx/ But am now seeing both applications fail to start. They offer only "See systemctl status or journalctl" as a way to view the problem, but those just tell me there was an exit code of 1. There's no "error in this file on this line" or anything helpful. Is there a way to see exactly what's wrong? I know it'll be some small syntax problem in one of the files, since I had to write them by hand over SSH rather than pasting. On Thu, May 5, 2016 at 1:30 PM, Anthony Ford wrote: > Hey Alex, > > Congrats on the progress so far. Let me see if I can clarify some things > for you > > 1. Is Mod_WSGI only for Apache? Should I stick with UWSGI, given that I'm >> using Nginx? >> > > Yes. Mod_WSGI is essentially a router that passes the request from Apache > (the url requested, HTTP headers, etc), and will accept the response from > your app and pass it back to Apache to send to the client. If you are using > Nginx, yes you should stick with uWSGI. > > > >> 2. I read that UWSGI is also a web server, and that it's suggested to use >> UWSGI with Nginx behind it. This seems more complicated than I expected. >> Did I understand it right? Is this a choice, or the only/best way to set >> things up? >> > > uWSGI can act as a standalone web-server for HTTP/S ( > http://uwsgi-docs.readthedocs.io/en/latest/HTTP.html#the-uwsgi-http-https-router). > If you have a heavy site (i.e. hundreds+ of active users), you will waste > efficiency and capacity by having uWSGI handle your static files (i.e. your > JS, images, etc.), so it is recommended to hide uWSGI behind an HTTP server > (i.e. Nginx) and let it handle the static loads since they are > significantly better at serving static files. > > No, you do not have to do this if you are building an internal or low use > site (but if the site is public, be prepared for traffic spikes that can > bring your site down, like slash-doting or reddit hug-of-deaths). Use the > `--http` option as suggesting in the above link. > > > >> 3. When all this is up and running, will views be relative to my app, or >> app/templates? That is, should I set the document root in Nginx to be >> /var/www/myApp, or /var/www/myApp/templates? The myApp folder has run.py, >> config.py, static/, and templates/. > > > If you are serving your app behind Nginx, the main document root (or > location in nginx parlance), i.e. /, would be your app in wsgi (the > uwsgi_pass section). The only thing Nginx should serve would be your static > files in `static/` (which should be served as `/static/`. > > I've stuck together a gist with some sanitized config files from a recent > project. You can find them here: > https://gist.github.com/ajford/32ca09c1bdb67e2211247f189aa2ae9a > > It's got some complexity (the vars in the wsgi definitions) because this > was running on an applications server with three different Flask based apps > running behind Nginx. In my case, while the number of users was low (~10 > max, more like a single user concurrent), I only had the one server > available, so they were placed behind Nginx to handle the virtual server > names (so the different apps wouldn't crash when serving). This may be > possible using uwsgi stand-alone, but I already knew how to do it in Nginx. > > Hope this helps! > > > > Anthony Ford, > KF5IBN, > ford.anthonyj at gmail.com > -- Alex Hall Automatic Distributors, IT department ahall at autodist.com -------------- next part -------------- An HTML attachment was scrubbed... URL: From ahall at autodist.com Thu May 5 14:12:09 2016 From: ahall at autodist.com (Alex Hall) Date: Thu, 5 May 2016 14:12:09 -0400 Subject: [Flask] Deploying Flask on Debian In-Reply-To: References: Message-ID: Well, I found Nginx logs in /var/log/nginx, which is great. Nginx is now working. I found UWSGI logs, too, but the only file in the folder is empty. UWSGI refuses to start, and I don't get why. The only log file is empty, and systemcpl status uwsgi.service doesn't really tell me anything. Anyone seen UWSGI do this? Any idea where it puts log files that will explain the problem? Thanks! On Thu, May 5, 2016 at 1:56 PM, Alex Hall wrote: > Thanks for the answers! > > At the risk of going a bit off topic, I made my Nginx and UWSGI > configuration files according to this guide: > http://www.markjberger.com/flask-with-virtualenv-uwsgi-nginx/ > > But am now seeing both applications fail to start. They offer only "See > systemctl status or journalctl" as a way to view the problem, but those > just tell me there was an exit code of 1. There's no "error in this file on > this line" or anything helpful. Is there a way to see exactly what's wrong? > I know it'll be some small syntax problem in one of the files, since I had > to write them by hand over SSH rather than pasting. > > On Thu, May 5, 2016 at 1:30 PM, Anthony Ford > wrote: > >> Hey Alex, >> >> Congrats on the progress so far. Let me see if I can clarify some things >> for you >> >> 1. Is Mod_WSGI only for Apache? Should I stick with UWSGI, given that I'm >>> using Nginx? >>> >> >> Yes. Mod_WSGI is essentially a router that passes the request from Apache >> (the url requested, HTTP headers, etc), and will accept the response from >> your app and pass it back to Apache to send to the client. If you are using >> Nginx, yes you should stick with uWSGI. >> >> >> >>> 2. I read that UWSGI is also a web server, and that it's suggested to >>> use UWSGI with Nginx behind it. This seems more complicated than I >>> expected. Did I understand it right? Is this a choice, or the only/best way >>> to set things up? >>> >> >> uWSGI can act as a standalone web-server for HTTP/S ( >> http://uwsgi-docs.readthedocs.io/en/latest/HTTP.html#the-uwsgi-http-https-router). >> If you have a heavy site (i.e. hundreds+ of active users), you will waste >> efficiency and capacity by having uWSGI handle your static files (i.e. your >> JS, images, etc.), so it is recommended to hide uWSGI behind an HTTP server >> (i.e. Nginx) and let it handle the static loads since they are >> significantly better at serving static files. >> >> No, you do not have to do this if you are building an internal or low use >> site (but if the site is public, be prepared for traffic spikes that can >> bring your site down, like slash-doting or reddit hug-of-deaths). Use the >> `--http` option as suggesting in the above link. >> >> >> >>> 3. When all this is up and running, will views be relative to my app, or >>> app/templates? That is, should I set the document root in Nginx to be >>> /var/www/myApp, or /var/www/myApp/templates? The myApp folder has run.py, >>> config.py, static/, and templates/. >> >> >> If you are serving your app behind Nginx, the main document root (or >> location in nginx parlance), i.e. /, would be your app in wsgi (the >> uwsgi_pass section). The only thing Nginx should serve would be your static >> files in `static/` (which should be served as `/static/`. >> >> I've stuck together a gist with some sanitized config files from a recent >> project. You can find them here: >> https://gist.github.com/ajford/32ca09c1bdb67e2211247f189aa2ae9a >> >> It's got some complexity (the vars in the wsgi definitions) because this >> was running on an applications server with three different Flask based apps >> running behind Nginx. In my case, while the number of users was low (~10 >> max, more like a single user concurrent), I only had the one server >> available, so they were placed behind Nginx to handle the virtual server >> names (so the different apps wouldn't crash when serving). This may be >> possible using uwsgi stand-alone, but I already knew how to do it in Nginx. >> >> Hope this helps! >> >> >> >> Anthony Ford, >> KF5IBN, >> ford.anthonyj at gmail.com >> > > > > -- > Alex Hall > Automatic Distributors, IT department > ahall at autodist.com > -- Alex Hall Automatic Distributors, IT department ahall at autodist.com -------------- next part -------------- An HTML attachment was scrubbed... URL: From and.damore at gmail.com Thu May 5 14:22:16 2016 From: and.damore at gmail.com (Andrea D'Amore) Date: Thu, 5 May 2016 20:22:16 +0200 Subject: [Flask] Deploying Flask on Debian In-Reply-To: <4E066FD5-E4B6-4EE1-B5C7-7E5F53FD0805@anu.edu.au> References: <4E066FD5-E4B6-4EE1-B5C7-7E5F53FD0805@anu.edu.au> Message-ID: On 3 May 2016 at 22:33, Adam Steer wrote: > I?ve just jumped through this same set of hoops, going from ?no idea? to ?flask = deployed on WSGI?, on ubuntu (nearly debian) and CentOS. [?] > I drew heavily on the deployment style here: > https://www.digitalocean.com/community/tutorials/how-to-deploy-a-flask-application-on-an-ubuntu-vps The main difference for the OP would be that on the Debian system he mentioned he'll need a systemd unit file. Btw I recently found a sysVinit debian server of mine I helped setting up went down and there was no backup of the init.d script I wrote to start the flask app with uwsgi. I'm reinstalling the app on an updated system that now has of course systemd, and since I've only touched systemd a couple of times, very sparse in time, I have to check the docs from the beginning. Does anyone have a uwsgi+flask systemd unit file example to share for starting an app as a system service? -- Andrea P.S. on other mailing lists I was explicitly told to "reply to all" when replying to the list, what's the policy here? From edwingate8 at gmail.com Thu May 5 14:24:54 2016 From: edwingate8 at gmail.com (Edward Wingate) Date: Thu, 5 May 2016 11:24:54 -0700 Subject: [Flask] Deploying Flask on Debian In-Reply-To: References: Message-ID: > At the risk of going a bit off topic, I made my Nginx and UWSGI > configuration files according to this guide: > http://www.markjberger.com/flask-with-virtualenv-uwsgi-nginx/ Here is another guide based on supervisor instead of systemd startup I followed a while back: http://ewong.me/creating-and-deploying-flask-app-using-uwsgi-nginx-virtualenv-and-supervisor/ Maybe you can use bits of it to get your setup working. From ahall at autodist.com Thu May 5 14:36:08 2016 From: ahall at autodist.com (Alex Hall) Date: Thu, 5 May 2016 14:36:08 -0400 Subject: [Flask] Deploying Flask on Debian In-Reply-To: References: Message-ID: Sorry for all the messages, but one more thing about UWSGI. There's one item in the configuration file sample I found that I don't understand: venv = /var/www/mysite/.env I can't find this venv item anywhere so far, and the author of the post where I found it never explained what it was for. Does it point to a special folder used during runtime? Does that folder have to exist first? Does this point to my app's folder, like chdir does? I don't have a .env folder, and I'm wondering if that's my problem. I don't want to make one, though, until I better understand what this venv item is actually trying to do. On Thu, May 5, 2016 at 2:24 PM, Edward Wingate wrote: > > At the risk of going a bit off topic, I made my Nginx and UWSGI > > configuration files according to this guide: > > http://www.markjberger.com/flask-with-virtualenv-uwsgi-nginx/ > > Here is another guide based on supervisor instead of systemd startup I > followed a while back: > > http://ewong.me/creating-and-deploying-flask-app-using-uwsgi-nginx-virtualenv-and-supervisor/ > > Maybe you can use bits of it to get your setup working. > -- Alex Hall Automatic Distributors, IT department ahall at autodist.com -------------- next part -------------- An HTML attachment was scrubbed... URL: From and.damore at gmail.com Thu May 5 14:38:55 2016 From: and.damore at gmail.com (Andrea D'Amore) Date: Thu, 5 May 2016 20:38:55 +0200 Subject: [Flask] Code evaluation In-Reply-To: References: Message-ID: On 5 May 2016 at 18:12, Mazzei, Stephen Andrew wrote: > was wondering if there is anyone who knows flask/python/mysqld pretty well > and can assist me and taking a look at the code, telling me how I am doing > wrong, how to make simple improvements so I can speed this process up. If you want an opinion just put the code -or a minimal example- someplace like bitbucket or github and paste the link, if anyone's willing to have a look he'll do. > In my mind this is a pretty straight database to webpage application, with > 90% of the entire page is just pulling the data and presenting it. We have a > few sections under the ?admin? pages to perform updates. For a similar task I used flask-admin to scaffold the admin part and custom views for the frontend. IIRC flask-admin does the frontend part as well so it could be a single solution, but I struggled understanding its code at first and I just did the front-end by hand. -- Andrea From coreybrett at gmail.com Thu May 5 14:41:33 2016 From: coreybrett at gmail.com (Corey Boyle) Date: Thu, 5 May 2016 14:41:33 -0400 Subject: [Flask] Deploying Flask on Debian In-Reply-To: References: Message-ID: That's where you specify the location of your virtualenv. On Thu, May 5, 2016 at 2:36 PM, Alex Hall wrote: > Sorry for all the messages, but one more thing about UWSGI. There's one item > in the configuration file sample I found that I don't understand: > > venv = /var/www/mysite/.env > > I can't find this venv item anywhere so far, and the author of the post > where I found it never explained what it was for. Does it point to a special > folder used during runtime? Does that folder have to exist first? Does this > point to my app's folder, like chdir does? I don't have a .env folder, and > I'm wondering if that's my problem. I don't want to make one, though, until > I better understand what this venv item is actually trying to do. > > On Thu, May 5, 2016 at 2:24 PM, Edward Wingate wrote: >> >> > At the risk of going a bit off topic, I made my Nginx and UWSGI >> > configuration files according to this guide: >> > http://www.markjberger.com/flask-with-virtualenv-uwsgi-nginx/ >> >> Here is another guide based on supervisor instead of systemd startup I >> followed a while back: >> >> http://ewong.me/creating-and-deploying-flask-app-using-uwsgi-nginx-virtualenv-and-supervisor/ >> >> Maybe you can use bits of it to get your setup working. > > > > > -- > Alex Hall > Automatic Distributors, IT department > ahall at autodist.com > > _______________________________________________ > Flask mailing list > Flask at python.org > https://mail.python.org/mailman/listinfo/flask > From Stephen.Mazzei at asrcfederal.com Thu May 5 14:48:47 2016 From: Stephen.Mazzei at asrcfederal.com (Mazzei, Stephen Andrew) Date: Thu, 5 May 2016 18:48:47 +0000 Subject: [Flask] Code evaluation In-Reply-To: References: Message-ID: Uploaded project to gitlab https://gitlab.com/mazzei.s/webtools.git --- Stephen A. Mazzei Systems Administrator | AFDS, ASRC Federal Data Solutions - P&G HPC Account | 513-634-9965 -----Original Message----- From: Andrea D'Amore [mailto:and.damore at gmail.com] Sent: Thursday, May 05, 2016 2:39 PM To: Mazzei, Stephen Andrew Cc: flask at python.org Subject: Re: [Flask] Code evaluation On 5 May 2016 at 18:12, Mazzei, Stephen Andrew wrote: > was wondering if there is anyone who knows flask/python/mysqld pretty > well and can assist me and taking a look at the code, telling me how I > am doing wrong, how to make simple improvements so I can speed this process up. If you want an opinion just put the code -or a minimal example- someplace like bitbucket or github and paste the link, if anyone's willing to have a look he'll do. > In my mind this is a pretty straight database to webpage application, > with 90% of the entire page is just pulling the data and presenting > it. We have a few sections under the ?admin? pages to perform updates. For a similar task I used flask-admin to scaffold the admin part and custom views for the frontend. IIRC flask-admin does the frontend part as well so it could be a single solution, but I struggled understanding its code at first and I just did the front-end by hand. -- Andrea ________________________________ The preceding message (including attachments) is covered by the Electronic Communication Privacy Act, 18 U.S.C. sections 2510-2512, is intended only for the person or entity to which it is addressed, and may contain information that is confidential, protected by attorney-client or other privilege, or otherwise protected from disclosure by law. If you are not the intended recipient, you are hereby notified that any retention, dissemination, distribution, or copying of this communication is strictly prohibited. Please reply to the sender that you have received the message in error and destroy the original message and all copies. From ahall at autodist.com Thu May 5 14:54:08 2016 From: ahall at autodist.com (Alex Hall) Date: Thu, 5 May 2016 14:54:08 -0400 Subject: [Flask] Deploying Flask on Debian In-Reply-To: References: Message-ID: Okay, thanks. Changing venv to match chdir seems to have worked. I still can't see my app, but at least UWSGI starts with no errors. Now to figure out how to let Nginx serve the pages to other computers on the intranet; this site is supposed to be a subdomain to a larger site, so I just want to map its IP to a subdomain on our internal DNS. Yet, [server_ip]/mySiteName returns a 404. Should be fun to troubleshoot. :) On Thu, May 5, 2016 at 2:41 PM, Corey Boyle wrote: > That's where you specify the location of your virtualenv. > > On Thu, May 5, 2016 at 2:36 PM, Alex Hall wrote: > > Sorry for all the messages, but one more thing about UWSGI. There's one > item > > in the configuration file sample I found that I don't understand: > > > > venv = /var/www/mysite/.env > > > > I can't find this venv item anywhere so far, and the author of the post > > where I found it never explained what it was for. Does it point to a > special > > folder used during runtime? Does that folder have to exist first? Does > this > > point to my app's folder, like chdir does? I don't have a .env folder, > and > > I'm wondering if that's my problem. I don't want to make one, though, > until > > I better understand what this venv item is actually trying to do. > > > > On Thu, May 5, 2016 at 2:24 PM, Edward Wingate > wrote: > >> > >> > At the risk of going a bit off topic, I made my Nginx and UWSGI > >> > configuration files according to this guide: > >> > http://www.markjberger.com/flask-with-virtualenv-uwsgi-nginx/ > >> > >> Here is another guide based on supervisor instead of systemd startup I > >> followed a while back: > >> > >> > http://ewong.me/creating-and-deploying-flask-app-using-uwsgi-nginx-virtualenv-and-supervisor/ > >> > >> Maybe you can use bits of it to get your setup working. > > > > > > > > > > -- > > Alex Hall > > Automatic Distributors, IT department > > ahall at autodist.com > > > > _______________________________________________ > > Flask mailing list > > Flask at python.org > > https://mail.python.org/mailman/listinfo/flask > > > -- Alex Hall Automatic Distributors, IT department ahall at autodist.com -------------- next part -------------- An HTML attachment was scrubbed... URL: From ford.anthonyj at gmail.com Thu May 5 16:21:10 2016 From: ford.anthonyj at gmail.com (Anthony Ford) Date: Thu, 5 May 2016 15:21:10 -0500 Subject: [Flask] Deploying Flask on Debian In-Reply-To: References: Message-ID: In your nginx conf for the specific app (the "server" section, https://gist.github.com/ajford/32ca09c1bdb67e2211247f189aa2ae9a#file-foobarapp-conf-L1 for example), you set the servername that you want to serve a specific site under (see https://gist.github.com/ajford/32ca09c1bdb67e2211247f189aa2ae9a#file-foobarapp-conf-L3). This is taken from the HTTP Host field. If you specify something on this line, the server won't respond properly if you access via some other host. For example, if you set servername to myserver.example.com, and go to the server's IP (i.e. 10.10.10.10/myapp/somepage), it won't respond, because Nginx doesn't know to dispatch the request to your app. If you put 10.10.10.10 in your hostfile as myserver.example.com, and go to myserver.example.com, it will work, as the Host field is now properly set. If you have an internal DNS resolver, you can add an alias or mapping for your server with the desired subdomain (this is what we did). If you are testing, and don't want to/can't set up a DNS or host record in your host file, or if you only have a single app, you can set the servername to *. This will cause Nginx to dispatch _ALL_ requests to your app. Anthony Ford, KF5IBN, ford.anthonyj at gmail.com On Thu, May 5, 2016 at 1:54 PM, Alex Hall wrote: > Okay, thanks. Changing venv to match chdir seems to have worked. I still > can't see my app, but at least UWSGI starts with no errors. Now to figure > out how to let Nginx serve the pages to other computers on the intranet; > this site is supposed to be a subdomain to a larger site, so I just want to > map its IP to a subdomain on our internal DNS. Yet, [server_ip]/mySiteName > returns a 404. Should be fun to troubleshoot. :) > > On Thu, May 5, 2016 at 2:41 PM, Corey Boyle wrote: > >> That's where you specify the location of your virtualenv. >> >> On Thu, May 5, 2016 at 2:36 PM, Alex Hall wrote: >> > Sorry for all the messages, but one more thing about UWSGI. There's one >> item >> > in the configuration file sample I found that I don't understand: >> > >> > venv = /var/www/mysite/.env >> > >> > I can't find this venv item anywhere so far, and the author of the post >> > where I found it never explained what it was for. Does it point to a >> special >> > folder used during runtime? Does that folder have to exist first? Does >> this >> > point to my app's folder, like chdir does? I don't have a .env folder, >> and >> > I'm wondering if that's my problem. I don't want to make one, though, >> until >> > I better understand what this venv item is actually trying to do. >> > >> > On Thu, May 5, 2016 at 2:24 PM, Edward Wingate >> wrote: >> >> >> >> > At the risk of going a bit off topic, I made my Nginx and UWSGI >> >> > configuration files according to this guide: >> >> > http://www.markjberger.com/flask-with-virtualenv-uwsgi-nginx/ >> >> >> >> Here is another guide based on supervisor instead of systemd startup I >> >> followed a while back: >> >> >> >> >> http://ewong.me/creating-and-deploying-flask-app-using-uwsgi-nginx-virtualenv-and-supervisor/ >> >> >> >> Maybe you can use bits of it to get your setup working. >> > >> > >> > >> > >> > -- >> > Alex Hall >> > Automatic Distributors, IT department >> > ahall at autodist.com >> > >> > _______________________________________________ >> > Flask mailing list >> > Flask at python.org >> > https://mail.python.org/mailman/listinfo/flask >> > >> > > > > -- > Alex Hall > Automatic Distributors, IT department > ahall at autodist.com > > _______________________________________________ > Flask mailing list > Flask at python.org > https://mail.python.org/mailman/listinfo/flask > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From ahall at autodist.com Fri May 6 10:15:29 2016 From: ahall at autodist.com (Alex Hall) Date: Fri, 6 May 2016 10:15:29 -0400 Subject: [Flask] Debugging "internal server error" with Flask, UWSGI, and Nginx? Message-ID: Hi all, I thought I'd start a new thread, as I've moved to a new step of this process. Nginx is working, and I can visit it from another computer, so that's great. The problem now is that, though I *should* see my Flask app's index page, I instead see "internal server error". No message, no traceback, no nothing. The Nginx log has no error in it, making me think it's a UWSGI problem. However, /var/log/uwsgi/app/myApp.log is completely blank. How would I go about determining the problem? I'm close to having this all work, but with no error messages or logs, I'm kind of stuck for the moment. Thanks for your patience and help. -- Alex Hall Automatic Distributors, IT department ahall at autodist.com -------------- next part -------------- An HTML attachment was scrubbed... URL: From giannis.pin at gmail.com Fri May 6 10:47:34 2016 From: giannis.pin at gmail.com (Ioannis Pinakoulakis) Date: Fri, 6 May 2016 16:47:34 +0200 Subject: [Flask] Debugging "internal server error" with Flask, UWSGI, and Nginx? In-Reply-To: References: Message-ID: Hi, Use the configuration propagate exceptions. You can find more details here: http://flask.pocoo.org/docs/0.10/config/ I hope this helps. Regards, Ioannis Pinakoulakis 6 maj 2016, 16:15, ?/? Alex Hall ??????: > Hi all, > I thought I'd start a new thread, as I've moved to a new step of this process. Nginx is working, and I can visit it from another computer, so that's great. The problem now is that, though I *should* see my Flask app's index page, I instead see "internal server error". No message, no traceback, no nothing. The Nginx log has no error in it, making me think it's a UWSGI problem. However, /var/log/uwsgi/app/myApp.log is completely blank. How would I go about determining the problem? I'm close to having this all work, but with no error messages or logs, I'm kind of stuck for the moment. Thanks for your patience and help. > > -- > Alex Hall > Automatic Distributors, IT department > ahall at autodist.com > _______________________________________________ > Flask mailing list > Flask at python.org > https://mail.python.org/mailman/listinfo/flask -------------- next part -------------- An HTML attachment was scrubbed... URL: From alejoar at gmail.com Fri May 6 10:48:54 2016 From: alejoar at gmail.com (Alejo Arias) Date: Fri, 6 May 2016 16:48:54 +0200 Subject: [Flask] Debugging "internal server error" with Flask, UWSGI, and Nginx? In-Reply-To: References: Message-ID: Hi Alex, if the app is not running in debug mode, it won't output any errors on response. You can use the logging module and set, for example, a FileHandler to save all the application errors/warnings to a file or even use the SMTPHandler to make the app send you and email with the error every time something goes wrong. There's good info on how to do this here: http://flask.pocoo.org/docs/0.10/errorhandling/ Regards, Alejo On 6 May 2016 at 16:15, Alex Hall wrote: > Hi all, > I thought I'd start a new thread, as I've moved to a new step of this > process. Nginx is working, and I can visit it from another computer, so > that's great. The problem now is that, though I *should* see my Flask app's > index page, I instead see "internal server error". No message, no > traceback, no nothing. The Nginx log has no error in it, making me think > it's a UWSGI problem. However, /var/log/uwsgi/app/myApp.log is completely > blank. How would I go about determining the problem? I'm close to having > this all work, but with no error messages or logs, I'm kind of stuck for > the moment. Thanks for your patience and help. > > -- > Alex Hall > Automatic Distributors, IT department > ahall at autodist.com > > _______________________________________________ > Flask mailing list > Flask at python.org > https://mail.python.org/mailman/listinfo/flask > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From ford.anthonyj at gmail.com Fri May 6 10:55:39 2016 From: ford.anthonyj at gmail.com (Anthony Ford) Date: Fri, 6 May 2016 09:55:39 -0500 Subject: [Flask] Debugging "internal server error" with Flask, UWSGI, and Nginx? In-Reply-To: References: Message-ID: Do you have DEBUG set in your app? If not, since you are still in testing, you should go ahead and enable it. That should get you the Werkzeug debugger, and help you resolve the problem. How are you running uwsgi? Supervisor? Systemd? You can also try running uwsgi standalone on the command line via the --http option. I find you get a bit more feedback from that, since it prints messages to the console. Once you have it running there, it should be easier to get it running behind Nginx, since you know the app already works. Anthony Ford, KF5IBN, ford.anthonyj at gmail.com On Fri, May 6, 2016 at 9:15 AM, Alex Hall wrote: > Hi all, > I thought I'd start a new thread, as I've moved to a new step of this > process. Nginx is working, and I can visit it from another computer, so > that's great. The problem now is that, though I *should* see my Flask app's > index page, I instead see "internal server error". No message, no > traceback, no nothing. The Nginx log has no error in it, making me think > it's a UWSGI problem. However, /var/log/uwsgi/app/myApp.log is completely > blank. How would I go about determining the problem? I'm close to having > this all work, but with no error messages or logs, I'm kind of stuck for > the moment. Thanks for your patience and help. > > -- > Alex Hall > Automatic Distributors, IT department > ahall at autodist.com > > _______________________________________________ > Flask mailing list > Flask at python.org > https://mail.python.org/mailman/listinfo/flask > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From ahall at autodist.com Fri May 6 11:56:53 2016 From: ahall at autodist.com (Alex Hall) Date: Fri, 6 May 2016 11:56:53 -0400 Subject: [Flask] Debugging "internal server error" with Flask, UWSGI, and Nginx? In-Reply-To: References: Message-ID: Hi all, Thanks for the quick responses. I should have said that yes, I'm running in debug mode; that's part of why I was so surprised to see this error with nothing else on the page. I'm not sure how I'm running UWSGI. The command I use, on Debian 8, is: sudo /etc/init.d/uwsgi [start/restart/stop] It starts with no errors, so must be working fine. I'll try running it by itself, which I've not done before, but keep in mind I have to be able to access this from another computer on the network. I can't run any GUI on this machine, so to test things, it has to be reachable on my physical computer. Still, assuming UWSGI can do that, running it directly is a good idea. Will that make me change any other configurations or settings, or can I leave everything in place and just run UWSGI? On Fri, May 6, 2016 at 10:47 AM, Ioannis Pinakoulakis wrote: > Hi, > > Use the configuration propagate exceptions. You can find more details > here: http://flask.pocoo.org/docs/0.10/config/ > > I hope this helps. > > Regards, > Ioannis Pinakoulakis > > 6 maj 2016, 16:15, ?/? Alex Hall ??????: > > Hi all, > I thought I'd start a new thread, as I've moved to a new step of this > process. Nginx is working, and I can visit it from another computer, so > that's great. The problem now is that, though I *should* see my Flask app's > index page, I instead see "internal server error". No message, no > traceback, no nothing. The Nginx log has no error in it, making me think > it's a UWSGI problem. However, /var/log/uwsgi/app/myApp.log is completely > blank. How would I go about determining the problem? I'm close to having > this all work, but with no error messages or logs, I'm kind of stuck for > the moment. Thanks for your patience and help. > > -- > Alex Hall > Automatic Distributors, IT department > ahall at autodist.com > > _______________________________________________ > Flask mailing list > Flask at python.org > https://mail.python.org/mailman/listinfo/flask > > -- Alex Hall Automatic Distributors, IT department ahall at autodist.com -------------- next part -------------- An HTML attachment was scrubbed... URL: From coreybrett at gmail.com Fri May 6 21:28:23 2016 From: coreybrett at gmail.com (Corey Boyle) Date: Fri, 6 May 2016 21:28:23 -0400 Subject: [Flask] add_template_global vs context_processor Message-ID: Does anyone know the difference between add_template_global and context_processor? I've used the template_global decorator to make a function available in my templates, but I would also like to make a particular variable available also. I seems like they both do similar things, but I don't know if there's something I am missing. Performance difference perhaps? From lormayna at gmail.com Sat May 7 18:18:26 2016 From: lormayna at gmail.com (Lorenzo Mainardi) Date: Sun, 8 May 2016 00:18:26 +0200 Subject: [Flask] Problem with Flask-Admin Message-ID: I have a problem with Flask-Admin This is my app.py: from flask import Flask from flask_sqlalchemy import SQLAlchemy from flask_bootstrap import Bootstrap from flask_wtf.csrf import CsrfProtect from flask.ext.admin import Admin from flask.ext.admin.contrib.sqla import ModelView import models app = Flask(__name__) app.secret_key = 'A0Zr98j/3yX R~XHH!jmN]LWX/,?RT' Bootstrap(app) app.config['SQLALCHEMY_DATABASE_URI'] = 'sqlite:////home/lorenzo/projects/digitel_task/app/app.db' app.config['SQLALCHEMY_TRACK_MODIFICATIONS'] = True db = SQLAlchemy(app) CsrfProtect(app) admin = Admin(app, name="Digitel Task System Admin") admin.add_view(ModelView(models.Status, db.session)) when i launch main.py I'm getting this error: (digitel_task)lorenzo at wolf:~/projects/digitel_task/app$ python main.py Traceback (most recent call last): File "main.py", line 1, in from models import * File "/home/lorenzo/projects/digitel_task/app/models.py", line 1, in from app import app,db File "/home/lorenzo/projects/digitel_task/app/app.py", line 20, in admin.add_view(ModelView(models.Status, db.session)) AttributeError: 'module' object has no attribute 'Status' I really don't know where is the problem. Could you help me? Thank you -- LORENZO MAINARDI http://blog.mainardi.me -------------- next part -------------- An HTML attachment was scrubbed... URL: From and.damore at gmail.com Sun May 8 12:07:51 2016 From: and.damore at gmail.com (Andrea D'Amore) Date: Sun, 8 May 2016 18:07:51 +0200 Subject: [Flask] Problem with Flask-Admin In-Reply-To: References: Message-ID: On 8 May 2016 at 00:18, Lorenzo Mainardi wrote: > AttributeError: 'module' object has no attribute 'Status' > > I really don't know where is the problem. > Could you help me? You need to paste (or attach if pasting isn't feasible) models.py, seems you think to have derived a SQLAlchemy Model there but the interpreter doesn't agree. As odd as it is you might be importing a "models" package from global site-package, what does models.__file__ say? -- Andrea From jiy_jiaqi at 163.com Sun May 8 22:45:52 2016 From: jiy_jiaqi at 163.com (jiy) Date: Mon, 9 May 2016 10:45:52 +0800 (CST) Subject: [Flask] Flask Digest, Vol 11, Issue 14 In-Reply-To: References: Message-ID: <3ca3031b.6223.15493681625.Coremail.jiy_jiaqi@163.com> subject -------------- next part -------------- An HTML attachment was scrubbed... URL: From lormayna at gmail.com Mon May 9 05:51:09 2016 From: lormayna at gmail.com (Lorenzo Mainardi) Date: Mon, 9 May 2016 11:51:09 +0200 Subject: [Flask] Problem with Flask-Admin In-Reply-To: References: Message-ID: This is my model.py file: (digitel_task)lorenzo at wolf:~/projects/digitel_task/app$ cat models.py from app import app,db class Task(db.Model): id = db.Column(db.Integer, primary_key=True) name = db.Column(db.String(40), unique=True) start_time = db.Column(db.DateTime) dpc = db.Column(db.DateTime) duc = db.Column(db.DateTime) end_time = db.Column(db.DateTime) tech_priority = db.Column(db.Integer, db.CheckConstraint('tech_priority>0'), db.CheckConstraint('tech_priority<3')) sales_priority = db.Column(db.Integer, db.CheckConstraint('tech_priority>0'), db.CheckConstraint('tech_priority<3')) description = db.Column(db.String(3000), unique=True) src_ip = db.Column(db.String(16), unique=True) class Employer(db.Model): id = db.Column(db.Integer, primary_key=True) name = db.Column(db.String(50), unique=True) class Status(db.Model): id = db.Column(db.Integer, primary_key=True) status = db.Column(db.String(50), unique=True) color = db.Column(db.String, unique = True) class MacroProject(db.Model): id = db.Column(db.Integer, primary_key=True) name = db.Column(db.String(40), unique=True) 2016-05-08 18:07 GMT+02:00 Andrea D'Amore : > On 8 May 2016 at 00:18, Lorenzo Mainardi wrote: > > AttributeError: 'module' object has no attribute 'Status' > > > > I really don't know where is the problem. > > Could you help me? > > You need to paste (or attach if pasting isn't feasible) models.py, > seems you think to have derived a SQLAlchemy Model there but the > interpreter doesn't agree. > > As odd as it is you might be importing a "models" package from global > site-package, what does models.__file__ say? > > > -- > Andrea > -- LORENZO MAINARDI http://blog.mainardi.me -------------- next part -------------- An HTML attachment was scrubbed... URL: From ford.anthonyj at gmail.com Mon May 9 07:52:45 2016 From: ford.anthonyj at gmail.com (Anthony Ford) Date: Mon, 9 May 2016 06:52:45 -0500 Subject: [Flask] Problem with Flask-Admin In-Reply-To: References: Message-ID: Um.. Then where's main.py? Can you paste as much of your app as you can disclose into a Gist/Pastebin? Or possibly a github/gitlab repo? Your app.py doesn't have the models import, so we can't see how things are imported there. Can you add a "print dir(models)" at the top of your main.py (after the import of course)? Just to see what's in that module. Also, like Andrea suggested, print models.__file__ as well. Just so we can make sure you are importing the file you think you are. Anthony Ford, KF5IBN, ford.anthonyj at gmail.com On Mon, May 9, 2016 at 4:51 AM, Lorenzo Mainardi wrote: > This is my model.py file: > > (digitel_task)lorenzo at wolf:~/projects/digitel_task/app$ cat models.py > > from app import app,db > class Task(db.Model): > id = db.Column(db.Integer, primary_key=True) > name = db.Column(db.String(40), unique=True) > start_time = db.Column(db.DateTime) > dpc = db.Column(db.DateTime) > duc = db.Column(db.DateTime) > end_time = db.Column(db.DateTime) > tech_priority = db.Column(db.Integer, > db.CheckConstraint('tech_priority>0'), > db.CheckConstraint('tech_priority<3')) > sales_priority = db.Column(db.Integer, > db.CheckConstraint('tech_priority>0'), > db.CheckConstraint('tech_priority<3')) > description = db.Column(db.String(3000), unique=True) > src_ip = db.Column(db.String(16), unique=True) > class Employer(db.Model): > id = db.Column(db.Integer, primary_key=True) > name = db.Column(db.String(50), unique=True) > class Status(db.Model): > id = db.Column(db.Integer, primary_key=True) > status = db.Column(db.String(50), unique=True) > color = db.Column(db.String, unique = True) > class MacroProject(db.Model): > id = db.Column(db.Integer, primary_key=True) > name = db.Column(db.String(40), unique=True) > > 2016-05-08 18:07 GMT+02:00 Andrea D'Amore : > >> On 8 May 2016 at 00:18, Lorenzo Mainardi wrote: >> > AttributeError: 'module' object has no attribute 'Status' >> > >> > I really don't know where is the problem. >> > Could you help me? >> >> You need to paste (or attach if pasting isn't feasible) models.py, >> seems you think to have derived a SQLAlchemy Model there but the >> interpreter doesn't agree. >> >> As odd as it is you might be importing a "models" package from global >> site-package, what does models.__file__ say? >> >> >> -- >> Andrea >> > > > > -- > LORENZO MAINARDI > http://blog.mainardi.me > > _______________________________________________ > Flask mailing list > Flask at python.org > https://mail.python.org/mailman/listinfo/flask > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From ddwiggins at advpubtech.com Mon May 9 13:55:01 2016 From: ddwiggins at advpubtech.com (Don Dwiggins) Date: Mon, 9 May 2016 10:55:01 -0700 Subject: [Flask] Question on Pluggable Views Message-ID: Has anyone here used pluggable views, as described in http://flask.pocoo.org/docs/0.10/views/ ? I'm curious about the role of the first argument to the "as_view" method of the View class. In the last example of the Basic Principle section, the text states " The class itself is instantiated with the parameters passed to the as_view() function.", but in the example, template_name is the only parameter to __init__; the first parameter to as_view, 'about_page', doesn't seem to be used. Experimenting a bit, I find that this first parameter needs to be present, and must be a string -- that's all. Actually, it's the parameters after the first that get passed to the __init__ method. In my code, I'm using an empty string for it in all cases, and it appears to work well. However, I have a nagging feeling that this first parameter ought to be useful for something. Any good thoughts welcome, -- Don Dwiggins Advanced Publishing Technology -------------- next part -------------- An HTML attachment was scrubbed... URL: From lormayna at gmail.com Mon May 9 16:06:52 2016 From: lormayna at gmail.com (Lorenzo Mainardi) Date: Mon, 9 May 2016 22:06:52 +0200 Subject: [Flask] Problem with Flask-Admin In-Reply-To: References: Message-ID: You can find the code here: https://bitbucket.org/lormayna/digi_task This is print dir(models): ['__builtins__', '__doc__', '__file__', '__name__', '__package__'] This is print models.__file__: /home/lorenzo/projects/digitel_task/app/models.pyc 2016-05-09 13:52 GMT+02:00 Anthony Ford : > Um.. Then where's main.py? > > Can you paste as much of your app as you can disclose into a > Gist/Pastebin? Or possibly a github/gitlab repo? > > Your app.py doesn't have the models import, so we can't see how things are > imported there. > > Can you add a "print dir(models)" at the top of your main.py (after the > import of course)? Just to see what's in that module. > Also, like Andrea suggested, print models.__file__ as well. Just so we can > make sure you are importing the file you think you are. > > > Anthony Ford, > KF5IBN, > ford.anthonyj at gmail.com > > On Mon, May 9, 2016 at 4:51 AM, Lorenzo Mainardi > wrote: > >> This is my model.py file: >> >> (digitel_task)lorenzo at wolf:~/projects/digitel_task/app$ cat models.py >> >> from app import app,db >> class Task(db.Model): >> id = db.Column(db.Integer, primary_key=True) >> name = db.Column(db.String(40), unique=True) >> start_time = db.Column(db.DateTime) >> dpc = db.Column(db.DateTime) >> duc = db.Column(db.DateTime) >> end_time = db.Column(db.DateTime) >> tech_priority = db.Column(db.Integer, >> db.CheckConstraint('tech_priority>0'), >> db.CheckConstraint('tech_priority<3')) >> sales_priority = db.Column(db.Integer, >> db.CheckConstraint('tech_priority>0'), >> db.CheckConstraint('tech_priority<3')) >> description = db.Column(db.String(3000), unique=True) >> src_ip = db.Column(db.String(16), unique=True) >> class Employer(db.Model): >> id = db.Column(db.Integer, primary_key=True) >> name = db.Column(db.String(50), unique=True) >> class Status(db.Model): >> id = db.Column(db.Integer, primary_key=True) >> status = db.Column(db.String(50), unique=True) >> color = db.Column(db.String, unique = True) >> class MacroProject(db.Model): >> id = db.Column(db.Integer, primary_key=True) >> name = db.Column(db.String(40), unique=True) >> >> 2016-05-08 18:07 GMT+02:00 Andrea D'Amore : >> >>> On 8 May 2016 at 00:18, Lorenzo Mainardi wrote: >>> > AttributeError: 'module' object has no attribute 'Status' >>> > >>> > I really don't know where is the problem. >>> > Could you help me? >>> >>> You need to paste (or attach if pasting isn't feasible) models.py, >>> seems you think to have derived a SQLAlchemy Model there but the >>> interpreter doesn't agree. >>> >>> As odd as it is you might be importing a "models" package from global >>> site-package, what does models.__file__ say? >>> >>> >>> -- >>> Andrea >>> >> >> >> >> -- >> LORENZO MAINARDI >> http://blog.mainardi.me >> >> _______________________________________________ >> Flask mailing list >> Flask at python.org >> https://mail.python.org/mailman/listinfo/flask >> >> > -- LORENZO MAINARDI http://blog.mainardi.me -------------- next part -------------- An HTML attachment was scrubbed... URL: From lps at chireiden.net Mon May 9 16:27:10 2016 From: lps at chireiden.net (Lars Peter =?UTF-8?B?U8O4bmRlcmdhYXJk?=) Date: Mon, 9 May 2016 22:27:10 +0200 Subject: [Flask] Question on Pluggable Views In-Reply-To: References: Message-ID: <20160509222710.5a974a59@ikarus> On Mon, 9 May 2016 10:55:01 -0700 Don Dwiggins wrote: > Has anyone here used pluggable views, as described in > http://flask.pocoo.org/docs/0.10/views/ ? > > I'm curious about the role of the first argument to the "as_view" > method of the View class. In the last example of the Basic Principle > section, the text states " The class itself is instantiated with the > parameters passed to the as_view() function.", but in the example, > template_name is the only parameter to __init__; the first parameter > to as_view, 'about_page', doesn't seem to be used. > > Experimenting a bit, I find that this first parameter needs to be > present, and must be a string -- that's all. Actually, it's the > parameters after the first that get passed to the __init__ method. > > In my code, I'm using an empty string for it in all cases, and it > appears to work well. However, I have a nagging feeling that this > first parameter ought to be useful for something. > > Any good thoughts welcome, The first arg "name" is used by the as_view classmethod itself. Any other argument that follows is used to instantiate the class. https://github.com/pallets/flask/blob/0.10.1/flask/views.py#L73 The "name" is the name of the endpoint. You should always specifiy it. It's the name you use, when you build URLs using the url_for() function. -- nitori -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 819 bytes Desc: OpenPGP digital signature URL: From and.damore at gmail.com Tue May 10 08:47:32 2016 From: and.damore at gmail.com (Andrea D'Amore) Date: Tue, 10 May 2016 14:47:32 +0200 Subject: [Flask] Problem with Flask-Admin In-Reply-To: References: Message-ID: On 9 May 2016 at 22:06, Lorenzo Mainardi wrote: > You can find the code here: > https://bitbucket.org/lormayna/digi_task > This is print dir(models): ['__builtins__', '__doc__', '__file__', > '__name__', '__package__'] > This is print models.__file__: > /home/lorenzo/projects/digitel_task/app/models.pyc I don't understand exactly what the issue is but I think it's a circular dependency one between app and models modules: app.py is importing from models.py that is importing from app. If you put print dir(models) just under "import models" in app.py you can see in the output that it's run twice, the first time the module has no attributes, and that's where you're getting the runtime error. The second time the models module is correctly showing the classes you defined, and that's the one you get if you try the code in an interactive interpreter and then try to manually execute admin.add_view() with models.Status, at that point models module is populated. -- Andrea From ahall at autodist.com Tue May 10 12:07:32 2016 From: ahall at autodist.com (Alex Hall) Date: Tue, 10 May 2016 12:07:32 -0400 Subject: [Flask] Finding error in Flask app while running under web server Message-ID: Hello list, I'm delighted to say that, not five minutes ago, my app ran under Nginx! I'm still not totally sure how it's doing it, but it is. Now, though, I'm running into a problem: something is timing out. I can see that in the Nginx log, and my page displays a generic error message, one it shows if anything goes sideways while talking to the database or interpreting results. I'm pretty sure the issue is in my app's communication with our AS400, but I don't know how to double check that. The UWSGI log for this app is empty, which doesn't surprise me as this is likely a problem with my app's code. Is Python logging the best way to go here, or is there some automated log I'm overlooking? Thanks for any answers, and thanks again for everyone's help. I'm thrilled that this finally--almost--works. It renders properly, which is the main thing. Hopefully, it'll all be downhill from here. :) -- Alex Hall Automatic Distributors, IT department ahall at autodist.com -------------- next part -------------- An HTML attachment was scrubbed... URL: From ford.anthonyj at gmail.com Tue May 10 12:35:20 2016 From: ford.anthonyj at gmail.com (Anthony Ford) Date: Tue, 10 May 2016 11:35:20 -0500 Subject: [Flask] Finding error in Flask app while running under web server In-Reply-To: References: Message-ID: Yeah, your best bet is probably to try some logging in Python. If I'm not mistaken, you can cheat by just "print"ing to STDOUT, and uwsgi should record that in its log, but in the long run, setting up proper logging is probably best (even with how much of a PITA the python logging module is). Anthony Ford, KF5IBN, ford.anthonyj at gmail.com On Tue, May 10, 2016 at 11:07 AM, Alex Hall wrote: > Hello list, > I'm delighted to say that, not five minutes ago, my app ran under Nginx! > I'm still not totally sure how it's doing it, but it is. Now, though, I'm > running into a problem: something is timing out. I can see that in the > Nginx log, and my page displays a generic error message, one it shows if > anything goes sideways while talking to the database or interpreting > results. > > I'm pretty sure the issue is in my app's communication with our AS400, but > I don't know how to double check that. The UWSGI log for this app is empty, > which doesn't surprise me as this is likely a problem with my app's code. > Is Python logging the best way to go here, or is there some automated log > I'm overlooking? > > Thanks for any answers, and thanks again for everyone's help. I'm thrilled > that this finally--almost--works. It renders properly, which is the main > thing. Hopefully, it'll all be downhill from here. :) > > -- > Alex Hall > Automatic Distributors, IT department > ahall at autodist.com > > _______________________________________________ > Flask mailing list > Flask at python.org > https://mail.python.org/mailman/listinfo/flask > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From ahall at autodist.com Tue May 10 12:41:57 2016 From: ahall at autodist.com (Alex Hall) Date: Tue, 10 May 2016 12:41:57 -0400 Subject: [Flask] Finding error in Flask app while running under web server In-Reply-To: References: Message-ID: Thanks, good to know I'm not missing another automatic log file somewhere. I also discovered that you can set catch-exceptions in UWSGI to true, and that will cause any problems to be printed. That may not help Flask directly, but it explains why my UWSGI log was always empty, as it showed a permissions problem with the file. If I printed with Flask, I wouldn't have seen anything, and I would never have known why were it not for catch-exceptions. On Tue, May 10, 2016 at 12:35 PM, Anthony Ford wrote: > Yeah, your best bet is probably to try some logging in Python. > > If I'm not mistaken, you can cheat by just "print"ing to STDOUT, and uwsgi > should record that in its log, but in the long run, setting up proper > logging is probably best (even with how much of a PITA the python logging > module is). > > > > Anthony Ford, > KF5IBN, > ford.anthonyj at gmail.com > > On Tue, May 10, 2016 at 11:07 AM, Alex Hall wrote: > >> Hello list, >> I'm delighted to say that, not five minutes ago, my app ran under Nginx! >> I'm still not totally sure how it's doing it, but it is. Now, though, I'm >> running into a problem: something is timing out. I can see that in the >> Nginx log, and my page displays a generic error message, one it shows if >> anything goes sideways while talking to the database or interpreting >> results. >> >> I'm pretty sure the issue is in my app's communication with our AS400, >> but I don't know how to double check that. The UWSGI log for this app is >> empty, which doesn't surprise me as this is likely a problem with my app's >> code. Is Python logging the best way to go here, or is there some automated >> log I'm overlooking? >> >> Thanks for any answers, and thanks again for everyone's help. I'm >> thrilled that this finally--almost--works. It renders properly, which is >> the main thing. Hopefully, it'll all be downhill from here. :) >> >> -- >> Alex Hall >> Automatic Distributors, IT department >> ahall at autodist.com >> >> _______________________________________________ >> Flask mailing list >> Flask at python.org >> https://mail.python.org/mailman/listinfo/flask >> >> > -- Alex Hall Automatic Distributors, IT department ahall at autodist.com -------------- next part -------------- An HTML attachment was scrubbed... URL: From ford.anthonyj at gmail.com Tue May 10 12:50:56 2016 From: ford.anthonyj at gmail.com (Anthony Ford) Date: Tue, 10 May 2016 11:50:56 -0500 Subject: [Flask] Finding error in Flask app while running under web server In-Reply-To: References: Message-ID: Good catch (no pun intended). Permissions with log files/dirs can be a big (and annoying) problem. You may have already found it, but there's a way to have uWSGI change log permissions (assuming you are starting uWSGI with high enough privs, such as using the uWSGI emperor or your systemd/sysinit). I use it in the gist I sent earlier ( https://gist.github.com/ajford/32ca09c1bdb67e2211247f189aa2ae9a#file-foobar-wsgi-L20), "log-chmod", and it's fellow, "log-chown". Only works if you do start with high/root privs and downgrade with the "uid" and "gid" flags. Oh software, the realm of debugging and logging. Anthony Ford, KF5IBN, ford.anthonyj at gmail.com On Tue, May 10, 2016 at 11:41 AM, Alex Hall wrote: > Thanks, good to know I'm not missing another automatic log file somewhere. > > I also discovered that you can set catch-exceptions in UWSGI to true, and > that will cause any problems to be printed. That may not help Flask > directly, but it explains why my UWSGI log was always empty, as it showed a > permissions problem with the file. If I printed with Flask, I wouldn't have > seen anything, and I would never have known why were it not for > catch-exceptions. > > > On Tue, May 10, 2016 at 12:35 PM, Anthony Ford > wrote: > >> Yeah, your best bet is probably to try some logging in Python. >> >> If I'm not mistaken, you can cheat by just "print"ing to STDOUT, and >> uwsgi should record that in its log, but in the long run, setting up proper >> logging is probably best (even with how much of a PITA the python logging >> module is). >> >> >> >> Anthony Ford, >> KF5IBN, >> ford.anthonyj at gmail.com >> >> On Tue, May 10, 2016 at 11:07 AM, Alex Hall wrote: >> >>> Hello list, >>> I'm delighted to say that, not five minutes ago, my app ran under Nginx! >>> I'm still not totally sure how it's doing it, but it is. Now, though, I'm >>> running into a problem: something is timing out. I can see that in the >>> Nginx log, and my page displays a generic error message, one it shows if >>> anything goes sideways while talking to the database or interpreting >>> results. >>> >>> I'm pretty sure the issue is in my app's communication with our AS400, >>> but I don't know how to double check that. The UWSGI log for this app is >>> empty, which doesn't surprise me as this is likely a problem with my app's >>> code. Is Python logging the best way to go here, or is there some automated >>> log I'm overlooking? >>> >>> Thanks for any answers, and thanks again for everyone's help. I'm >>> thrilled that this finally--almost--works. It renders properly, which is >>> the main thing. Hopefully, it'll all be downhill from here. :) >>> >>> -- >>> Alex Hall >>> Automatic Distributors, IT department >>> ahall at autodist.com >>> >>> _______________________________________________ >>> Flask mailing list >>> Flask at python.org >>> https://mail.python.org/mailman/listinfo/flask >>> >>> >> > > > -- > Alex Hall > Automatic Distributors, IT department > ahall at autodist.com > -------------- next part -------------- An HTML attachment was scrubbed... URL: From ahall at autodist.com Tue May 10 15:02:07 2016 From: ahall at autodist.com (Alex Hall) Date: Tue, 10 May 2016 15:02:07 -0400 Subject: [Flask] Restarting Flask app? Message-ID: Hi all, It just struck me that restarting a Flask app after modifying the Python code isn't obvious. Do I restart UWSGI, Nginx, or both? In UWSGI, I specified "master=true", which I read lets you apply changes without restarting. Therefore, do I need to restart anything, or simply save my changes to the code and watch it happen automatically? -- Alex Hall Automatic Distributors, IT department ahall at autodist.com -------------- next part -------------- An HTML attachment was scrubbed... URL: From gatzby3jr at gmail.com Tue May 10 15:11:53 2016 From: gatzby3jr at gmail.com (Brian O'Connor) Date: Tue, 10 May 2016 15:11:53 -0400 Subject: [Flask] Restarting Flask app? In-Reply-To: References: Message-ID: This page may be of use to you: http://uwsgi-docs.readthedocs.io/en/latest/articles/TheArtOfGracefulReloading.html Personally, I use the --touch-reload option. On Tue, May 10, 2016 at 3:02 PM, Alex Hall wrote: > Hi all, > It just struck me that restarting a Flask app after modifying the Python > code isn't obvious. Do I restart UWSGI, Nginx, or both? In UWSGI, I > specified "master=true", which I read lets you apply changes without > restarting. Therefore, do I need to restart anything, or simply save my > changes to the code and watch it happen automatically? > > -- > Alex Hall > Automatic Distributors, IT department > ahall at autodist.com > > _______________________________________________ > Flask mailing list > Flask at python.org > https://mail.python.org/mailman/listinfo/flask > > -- Brian O'Connor -------------- next part -------------- An HTML attachment was scrubbed... URL: From davidism at gmail.com Tue May 10 15:05:39 2016 From: davidism at gmail.com (David Lord) Date: Tue, 10 May 2016 12:05:39 -0700 Subject: [Flask] Restarting Flask app? In-Reply-To: References: Message-ID: You restart the process running your app, which is uWSGI. `master` does not mean that, it means that you're starting a process that will manage other processes. Although there are solutions for restarting when files change, you should always restart manually in production. On Tue, May 10, 2016 at 12:02 PM, Alex Hall wrote: > Hi all, > It just struck me that restarting a Flask app after modifying the Python > code isn't obvious. Do I restart UWSGI, Nginx, or both? In UWSGI, I > specified "master=true", which I read lets you apply changes without > restarting. Therefore, do I need to restart anything, or simply save my > changes to the code and watch it happen automatically? > > -- > Alex Hall > Automatic Distributors, IT department > ahall at autodist.com > > _______________________________________________ > Flask mailing list > Flask at python.org > https://mail.python.org/mailman/listinfo/flask > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From ahall at autodist.com Tue May 10 15:26:20 2016 From: ahall at autodist.com (Alex Hall) Date: Tue, 10 May 2016 15:26:20 -0400 Subject: [Flask] Restarting Flask app? In-Reply-To: References: Message-ID: Great, thanks. So UWSGI is what I'd restart. There must be a way to script all this, so I don't have to keep doing sudo uwsgi --ini-paste /etc/uwsgi/apps-enabled/myApp.ini Great point about not auto-restarting on a production site. For testing it's super convenient, but you're right, it would be horrible on something real, especially as I'm in the habbit of hitting ctrl-s every few minutes no matter whether my code is valid at the moment or not. On Tue, May 10, 2016 at 3:05 PM, David Lord wrote: > You restart the process running your app, which is uWSGI. `master` does > not mean that, it means that you're starting a process that will manage > other processes. Although there are solutions for restarting when files > change, you should always restart manually in production. > > On Tue, May 10, 2016 at 12:02 PM, Alex Hall wrote: > >> Hi all, >> It just struck me that restarting a Flask app after modifying the Python >> code isn't obvious. Do I restart UWSGI, Nginx, or both? In UWSGI, I >> specified "master=true", which I read lets you apply changes without >> restarting. Therefore, do I need to restart anything, or simply save my >> changes to the code and watch it happen automatically? >> >> -- >> Alex Hall >> Automatic Distributors, IT department >> ahall at autodist.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 > > -- Alex Hall Automatic Distributors, IT department ahall at autodist.com -------------- next part -------------- An HTML attachment was scrubbed... URL: From davidism at gmail.com Tue May 10 16:18:15 2016 From: davidism at gmail.com (David Lord) Date: Tue, 10 May 2016 13:18:15 -0700 Subject: [Flask] Restarting Flask app? In-Reply-To: References: Message-ID: http://supervisord.org/ On Tue, May 10, 2016 at 12:26 PM, Alex Hall wrote: > Great, thanks. So UWSGI is what I'd restart. There must be a way to script > all this, so I don't have to keep doing > sudo uwsgi --ini-paste /etc/uwsgi/apps-enabled/myApp.ini > > Great point about not auto-restarting on a production site. For testing > it's super convenient, but you're right, it would be horrible on something > real, especially as I'm in the habbit of hitting ctrl-s every few minutes > no matter whether my code is valid at the moment or not. > > On Tue, May 10, 2016 at 3:05 PM, David Lord wrote: > >> You restart the process running your app, which is uWSGI. `master` does >> not mean that, it means that you're starting a process that will manage >> other processes. Although there are solutions for restarting when files >> change, you should always restart manually in production. >> >> On Tue, May 10, 2016 at 12:02 PM, Alex Hall wrote: >> >>> Hi all, >>> It just struck me that restarting a Flask app after modifying the Python >>> code isn't obvious. Do I restart UWSGI, Nginx, or both? In UWSGI, I >>> specified "master=true", which I read lets you apply changes without >>> restarting. Therefore, do I need to restart anything, or simply save my >>> changes to the code and watch it happen automatically? >>> >>> -- >>> Alex Hall >>> Automatic Distributors, IT department >>> ahall at autodist.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 >> >> > > > -- > Alex Hall > Automatic Distributors, IT department > ahall at autodist.com > -------------- next part -------------- An HTML attachment was scrubbed... URL: From lormayna at gmail.com Tue May 10 16:47:02 2016 From: lormayna at gmail.com (Lorenzo Mainardi) Date: Tue, 10 May 2016 22:47:02 +0200 Subject: [Flask] Problem with Flask-Admin In-Reply-To: References: Message-ID: Thank you, now it seems working fine. 2016-05-10 14:47 GMT+02:00 Andrea D'Amore : > On 9 May 2016 at 22:06, Lorenzo Mainardi wrote: > > You can find the code here: > > https://bitbucket.org/lormayna/digi_task > > > This is print dir(models): ['__builtins__', '__doc__', '__file__', > > '__name__', '__package__'] > > This is print models.__file__: > > /home/lorenzo/projects/digitel_task/app/models.pyc > > I don't understand exactly what the issue is but I think it's a > circular dependency one between app and models modules: app.py is > importing from models.py that is importing from app. > If you put print dir(models) just under "import models" in app.py you > can see in the output that it's run twice, the first time the module > has no attributes, and that's where you're getting the runtime error. > The second time the models module is correctly showing the classes you > defined, and that's the one you get if you try the code in an > interactive interpreter and then try to manually execute > admin.add_view() with models.Status, at that point models module is > populated. > > > -- > Andrea > -- LORENZO MAINARDI http://blog.mainardi.me -------------- next part -------------- An HTML attachment was scrubbed... URL: From ahall at autodist.com Tue May 10 17:40:53 2016 From: ahall at autodist.com (Alex Hall) Date: Tue, 10 May 2016 17:40:53 -0400 Subject: [Flask] Particular order for starting Nginx/UWSGI? Message-ID: Hi all, I'm suddenly getting errors, where the socket used by Nginx and UWSGI isn't reachable because of permission problems. This didn't happen until I restarted both services (Nginx was acting up; I didn't restart it to try to restart my app). Is there a specific order in which these pieces have to be started or stopped to avoid problems, or is this something different? I didn't change the socket details in any configuration file, so it almost has to be the restarting of both services. Thanks. -- Alex Hall Automatic Distributors, IT department ahall at autodist.com -------------- next part -------------- An HTML attachment was scrubbed... URL: From ford.anthonyj at gmail.com Tue May 10 18:23:28 2016 From: ford.anthonyj at gmail.com (Anthony Ford) Date: Tue, 10 May 2016 17:23:28 -0500 Subject: [Flask] Particular order for starting Nginx/UWSGI? In-Reply-To: References: Message-ID: As far as I know, only the uWSGI process creates the sockets. Are you using unix sockets or network sockets? Every time I've tried to get unix socks working, I've run into a permissions issue, and I've never had enough time to figure it out. Perhaps someone else on the list can point you in the right way. Maybe you can try chmoding to 777 and see if that helps. I usually go for network sockets bound to 127.0.0.1 for security ("socket = 127.0.0.1:7000"). If you are using unix socks, you might also try the chown-socket and chmod-socket commands and set to the user/group your web server runs as (usually something like www or nginx) and a 660, 666, or 777. Anthony Ford, KF5IBN, ford.anthonyj at gmail.com On Tue, May 10, 2016 at 4:40 PM, Alex Hall wrote: > Hi all, > I'm suddenly getting errors, where the socket used by Nginx and UWSGI > isn't reachable because of permission problems. This didn't happen until I > restarted both services (Nginx was acting up; I didn't restart it to try to > restart my app). Is there a specific order in which these pieces have to be > started or stopped to avoid problems, or is this something different? I > didn't change the socket details in any configuration file, so it almost > has to be the restarting of both services. Thanks. > > -- > Alex Hall > Automatic Distributors, IT department > ahall at autodist.com > > _______________________________________________ > Flask mailing list > Flask at python.org > https://mail.python.org/mailman/listinfo/flask > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From ahall at autodist.com Tue May 10 20:12:14 2016 From: ahall at autodist.com (Alex Hall) Date: Tue, 10 May 2016 20:12:14 -0400 Subject: [Flask] Particular order for starting Nginx/UWSGI? In-Reply-To: References: Message-ID: <13390471-2A6F-40E9-BDAF-55F75970C8AB@autodist.com> Yep, you got me. Unix sockets, because I read they're faster, and because punching holes in the Google Cloud firewall is a pain/must be approved by my boss. :) Although, maybe it won't need holes if it's all based on localhost--that's a good thought. I'll switch over to HTTP sockets tomorrow and see if that makes a difference. Thanks. > On May 10, 2016, at 18:23, Anthony Ford wrote: > > As far as I know, only the uWSGI process creates the sockets. Are you using unix sockets or network sockets? > > Every time I've tried to get unix socks working, I've run into a permissions issue, and I've never had enough time to figure it out. Perhaps someone else on the list can point you in the right way. Maybe you can try chmoding to 777 and see if that helps. > > I usually go for network sockets bound to 127.0.0.1 for security ("socket = 127.0.0.1:7000 "). If you are using unix socks, you might also try the chown-socket and chmod-socket commands and set to the user/group your web server runs as (usually something like www or nginx) and a 660, 666, or 777. > > > > Anthony Ford, > KF5IBN, > ford.anthonyj at gmail.com > On Tue, May 10, 2016 at 4:40 PM, Alex Hall > wrote: > Hi all, > I'm suddenly getting errors, where the socket used by Nginx and UWSGI isn't reachable because of permission problems. This didn't happen until I restarted both services (Nginx was acting up; I didn't restart it to try to restart my app). Is there a specific order in which these pieces have to be started or stopped to avoid problems, or is this something different? I didn't change the socket details in any configuration file, so it almost has to be the restarting of both services. Thanks. > > -- > Alex Hall > Automatic Distributors, IT department > ahall at autodist.com > > _______________________________________________ > Flask mailing list > Flask at python.org > https://mail.python.org/mailman/listinfo/flask > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From ford.anthonyj at gmail.com Tue May 10 20:16:41 2016 From: ford.anthonyj at gmail.com (Anthony Ford) Date: Tue, 10 May 2016 19:16:41 -0500 Subject: [Flask] Particular order for starting Nginx/UWSGI? In-Reply-To: <13390471-2A6F-40E9-BDAF-55F75970C8AB@autodist.com> References: <13390471-2A6F-40E9-BDAF-55F75970C8AB@autodist.com> Message-ID: Yeah, you shouldn't need to touch the firewall since it's entirely local (IIRC that's caught at the kernel layer in most linuxes and routed without ever really hitting the network stack or hw). I'm sure there's a way to do it with unix socks. It's a standard (and sometimes preferred) way of doing it. I've just never managed to get it right. With some effort, and perhaps some help from someone else on the mailinglist, I'm sure you can get the unix socks working. And if you do, let me know how! Anthony Ford, KF5IBN, ford.anthonyj at gmail.com On Tue, May 10, 2016 at 7:12 PM, Alex Hall wrote: > Yep, you got me. Unix sockets, because I read they're faster, and because > punching holes in the Google Cloud firewall is a pain/must be approved by > my boss. :) Although, maybe it won't need holes if it's all based on > localhost--that's a good thought. I'll switch over to HTTP sockets tomorrow > and see if that makes a difference. Thanks. > > On May 10, 2016, at 18:23, Anthony Ford wrote: > > As far as I know, only the uWSGI process creates the sockets. Are you > using unix sockets or network sockets? > > Every time I've tried to get unix socks working, I've run into a > permissions issue, and I've never had enough time to figure it out. Perhaps > someone else on the list can point you in the right way. Maybe you can try > chmoding to 777 and see if that helps. > > I usually go for network sockets bound to 127.0.0.1 for security ("socket > = 127.0.0.1:7000"). If you are using unix socks, you might also try the > chown-socket and chmod-socket commands and set to the user/group your web > server runs as (usually something like www or nginx) and a 660, 666, or 777. > > > > Anthony Ford, > KF5IBN, > ford.anthonyj at gmail.com > > On Tue, May 10, 2016 at 4:40 PM, Alex Hall wrote: > >> Hi all, >> I'm suddenly getting errors, where the socket used by Nginx and UWSGI >> isn't reachable because of permission problems. This didn't happen until I >> restarted both services (Nginx was acting up; I didn't restart it to try to >> restart my app). Is there a specific order in which these pieces have to be >> started or stopped to avoid problems, or is this something different? I >> didn't change the socket details in any configuration file, so it almost >> has to be the restarting of both services. Thanks. >> >> -- >> Alex Hall >> Automatic Distributors, IT department >> ahall at autodist.com >> >> _______________________________________________ >> Flask mailing list >> Flask at python.org >> https://mail.python.org/mailman/listinfo/flask >> >> > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From scott.massey at gmail.com Tue May 10 20:58:36 2016 From: scott.massey at gmail.com (Scott Massey) Date: Wed, 11 May 2016 09:58:36 +0900 Subject: [Flask] SQLAlchemy + pagination + MySQL problems Message-ID: I started getting this error when I switched from msqlite to MariaDB on a digital ocean droplet. The syntax of how the ORM generates the query seems to be the problem, but I don't know how to fix it. Changing the paginate parameters such as 'per_page' only makes the params show as '-20, 20', for example. See the error below: sqlalchemy.exc.ProgrammingError ProgrammingError: (pymysql.err.ProgrammingError) (1064, u"You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near '-10, 10' at line 3") [SQL: u'SELECT post.id AS post_id, post.title AS post_title, post.text AS post_text, post.publish_date AS post_publish_date, post.user_id AS post_user_id \nFROM post ORDER BY post.publish_date DESC \n LIMIT %(param_1)s, %(param_2)s'] [parameters: {u'param_1': -10, u'param_2': 10}] Here is the line that queries for posts: @blog_blueprint.route('/') @blog_blueprint.route('/') @cache.cached(timeout=60) def home(page=1): posts = Post.query.order_by(Post.publish_date.desc()).paginate(page, 10) recent, top_tags = sidebar_data() return render_template( 'home.html', posts=posts, recent=recent, top_tags=top_tags ) This first query fails with that same error, the second works via CLI, so this seems to be what flask is sending to MySQL: MariaDB [flaskblog]> SELECT post.id AS post_id, post.title AS post_title, post.text AS post_text, post.publish_date AS post_publish_date, post.user_id AS post_user_id \n FROM post ORDER BY post.publish_date DESC LIMIT -10, 10; MariaDB [flaskblog]> SELECT post.id AS post_id, post.title AS post_title, post.text AS post_text, post.publish_date AS post_publish_date, post.user_id AS post_user_id \n FROM post ORDER BY post.publish_date DESC LIMIT 0, 10; I am about to just take pagination out, because it's my first flask project and it's just a blog, but I have spent hours banging my head. Thanks! Scott -------------- next part -------------- An HTML attachment was scrubbed... URL: From and.damore at gmail.com Wed May 11 01:45:42 2016 From: and.damore at gmail.com (Andrea D'Amore) Date: Wed, 11 May 2016 07:45:42 +0200 Subject: [Flask] Problem with Flask-Admin In-Reply-To: References: Message-ID: On 10 May 2016 at 22:47, Lorenzo Mainardi wrote: > Thank you, now it seems working fine. Well, don't keep us hanging, tell the list how did you manage to solve the problem. I later tried to reduce the issue -see SSCCE [1] , it's a _very_ insightful process for issue you don't see at first glance- and just to clarify the circularity of your issue here's an example made of two files, main.py and secondary.py # FILE main.py import secondary class Foo: message = "I'm Foo" print(secondary.__file__) print(dir(secondary)) # trying the following line in interactive intepreter will throw an exception #b = secondary.Bar() # FILE secondary.py from main import Foo class Bar(Foo): message = "I'm Bar" Running main from command line will result in the same behavior. [1] http://sscce.org/ -- Andrea From and.damore at gmail.com Wed May 11 02:04:17 2016 From: and.damore at gmail.com (Andrea D'Amore) Date: Wed, 11 May 2016 08:04:17 +0200 Subject: [Flask] SQLAlchemy + pagination + MySQL problems In-Reply-To: References: Message-ID: On 11 May 2016 at 02:58, Scott Massey wrote: > [parameters: {u'param_1': -10, u'param_2': 10}] > AS post_user_id \n FROM post ORDER BY post.publish_date DESC LIMIT -10, 10; I see why the DBMS is annoyed at that -10. This is likely Flask-SQLAlchemy specific, can you provide a minimal example? I figure that inspecting a bit the Paginate instance would give you some answer, and flask-sqlalchemy is a thin layer IIRC so shouldn't be too hard to look around. -- Andrea From ahall at autodist.com Wed May 11 09:22:01 2016 From: ahall at autodist.com (Alex Hall) Date: Wed, 11 May 2016 09:22:01 -0400 Subject: [Flask] "could not build URL for endpoint"? Message-ID: Hello list, I have no idea what I changed--I've been messing with so many config files and apps lately--but suddenly I'm getting that error when I load my app. My templates use the 'url_for' function, as I'm told they should, but that seems to be failing for some reason. The only related change I can think of is that I recently added a couple more decorators to a view function, in an effort to always direct to a certain view when visitors go to the main site. That is myapp.mysite.com/search is redirected to by myapp.mysite.com or myapp.mysite.com/index The error is "could not build URL for endpoint '/index'. Did you mean '/search' instead? In my base template, I define a navigation bar. In the exception, the first url in that bar is causing the problem: a href="{{url_for("/index")}}">Home From ford.anthonyj at gmail.com Wed May 11 09:32:45 2016 From: ford.anthonyj at gmail.com (Anthony Ford) Date: Wed, 11 May 2016 08:32:45 -0500 Subject: [Flask] "could not build URL for endpoint"? In-Reply-To: References: Message-ID: Your running into an uissue in that url_for doesn't take the path ( the "/foo/bar" in "example.com/foo/bar") but the function which provides the view you want. If you define a route (say "/index"), and the function that handles that route is foobar(), then you would use url_for('foobar'). So for: @app.route('/index') def foobar(): return render_template('foobar.html') your template would have the following link: a href="{{url_for('.foobar')}}">Home wrote: > Hello list, > I have no idea what I changed--I've been messing with so many config files > and apps lately--but suddenly I'm getting that error when I load my app. My > templates use the 'url_for' function, as I'm told they should, but that > seems to be failing for some reason. The only related change I can think of > is that I recently added a couple more decorators to a view function, in an > effort to always direct to a certain view when visitors go to the main > site. That is > myapp.mysite.com/search > is redirected to by > myapp.mysite.com > or > myapp.mysite.com/index > > The error is "could not build URL for endpoint '/index'. Did you mean > '/search' instead? > > In my base template, I define a navigation bar. In the exception, the > first url in that bar is causing the problem: > a href="{{url_for("/index")}}">Home > Might the problem be that I'm defining a link (/index) that will render as > this view, because that's a decorator before the /search function? That > doesn't make much sense to me, but I can't think what else it could be. > Related: is there a better way of directing to a certain view than putting > a bunch of app.route decorators in front of a single function? Is the > recommended way to handle this in the web server configuration instead? > > > -- > Alex Hall > Automatic Distributors, IT department > ahall at autodist.com > > _______________________________________________ > Flask mailing list > Flask at python.org > https://mail.python.org/mailman/listinfo/flask > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From ford.anthonyj at gmail.com Wed May 11 09:35:25 2016 From: ford.anthonyj at gmail.com (Anthony Ford) Date: Wed, 11 May 2016 08:35:25 -0500 Subject: [Flask] "could not build URL for endpoint"? In-Reply-To: References: Message-ID: Forgot to give you these links on url_for: http://flask.pocoo.org/docs/0.10/api/#flask.url_for http://flask.pocoo.org/docs/0.10/blueprints/#building-urls Anthony Ford, KF5IBN, ford.anthonyj at gmail.com On Wed, May 11, 2016 at 8:32 AM, Anthony Ford wrote: > Your running into an uissue in that url_for doesn't take the path ( the > "/foo/bar" in "example.com/foo/bar") but the function which provides the > view you want. > > If you define a route (say "/index"), and the function that handles that > route is foobar(), then you would use url_for('foobar'). > > So for: > > @app.route('/index') > def foobar(): > return render_template('foobar.html') > > > your template would have the following link: > > a href="{{url_for('.foobar')}}">Home > > Hope that helps! > > Also, be careful with your quotes. While Jinja should pick up the quotes > within {{}} and handle them well, even with the outer quotes, it's good to > be in the habit of not mixing quotes. Use one type (i.e. double) for your > outer, and the other (single) for your inner. Since Python doesn't > differentiate between the types, it's safe to swap them as you desire. > > > > Anthony Ford, > KF5IBN, > ford.anthonyj at gmail.com > > On Wed, May 11, 2016 at 8:22 AM, Alex Hall wrote: > >> Hello list, >> I have no idea what I changed--I've been messing with so many config >> files and apps lately--but suddenly I'm getting that error when I load my >> app. My templates use the 'url_for' function, as I'm told they should, but >> that seems to be failing for some reason. The only related change I can >> think of is that I recently added a couple more decorators to a view >> function, in an effort to always direct to a certain view when visitors go >> to the main site. That is >> myapp.mysite.com/search >> is redirected to by >> myapp.mysite.com >> or >> myapp.mysite.com/index >> >> The error is "could not build URL for endpoint '/index'. Did you mean >> '/search' instead? >> >> In my base template, I define a navigation bar. In the exception, the >> first url in that bar is causing the problem: >> a href="{{url_for("/index")}}">Home> >> Might the problem be that I'm defining a link (/index) that will render >> as this view, because that's a decorator before the /search function? That >> doesn't make much sense to me, but I can't think what else it could be. >> Related: is there a better way of directing to a certain view than putting >> a bunch of app.route decorators in front of a single function? Is the >> recommended way to handle this in the web server configuration instead? >> >> >> -- >> Alex Hall >> Automatic Distributors, IT department >> ahall at autodist.com >> >> _______________________________________________ >> Flask mailing list >> Flask at python.org >> https://mail.python.org/mailman/listinfo/flask >> >> > -------------- next part -------------- An HTML attachment was scrubbed... URL: From ahall at autodist.com Wed May 11 09:36:55 2016 From: ahall at autodist.com (Alex Hall) Date: Wed, 11 May 2016 09:36:55 -0400 Subject: [Flask] "could not build URL for endpoint"? In-Reply-To: References: Message-ID: Okay, thanks--that explains a lot! I had a function called 'index', but moved my decorators for / and /index off of it. I didn't realize url_for worked that way, so I was calling a function that had no app.route decorators. This explains so much. Your example said to use url_for('.foobar')}}. Was the period supposed to be before the function name, or was that a typo? Just want to make sure there's not some other aspect I'm missing. Thanks. On Wed, May 11, 2016 at 9:32 AM, Anthony Ford wrote: > Your running into an uissue in that url_for doesn't take the path ( the > "/foo/bar" in "example.com/foo/bar") but the function which provides the > view you want. > > If you define a route (say "/index"), and the function that handles that > route is foobar(), then you would use url_for('foobar'). > > So for: > > @app.route('/index') > def foobar(): > return render_template('foobar.html') > > > your template would have the following link: > > a href="{{url_for('.foobar')}}">Home > > Hope that helps! > > Also, be careful with your quotes. While Jinja should pick up the quotes > within {{}} and handle them well, even with the outer quotes, it's good to > be in the habit of not mixing quotes. Use one type (i.e. double) for your > outer, and the other (single) for your inner. Since Python doesn't > differentiate between the types, it's safe to swap them as you desire. > > > > Anthony Ford, > KF5IBN, > ford.anthonyj at gmail.com > > On Wed, May 11, 2016 at 8:22 AM, Alex Hall wrote: > >> Hello list, >> I have no idea what I changed--I've been messing with so many config >> files and apps lately--but suddenly I'm getting that error when I load my >> app. My templates use the 'url_for' function, as I'm told they should, but >> that seems to be failing for some reason. The only related change I can >> think of is that I recently added a couple more decorators to a view >> function, in an effort to always direct to a certain view when visitors go >> to the main site. That is >> myapp.mysite.com/search >> is redirected to by >> myapp.mysite.com >> or >> myapp.mysite.com/index >> >> The error is "could not build URL for endpoint '/index'. Did you mean >> '/search' instead? >> >> In my base template, I define a navigation bar. In the exception, the >> first url in that bar is causing the problem: >> a href="{{url_for("/index")}}">Home> >> Might the problem be that I'm defining a link (/index) that will render >> as this view, because that's a decorator before the /search function? That >> doesn't make much sense to me, but I can't think what else it could be. >> Related: is there a better way of directing to a certain view than putting >> a bunch of app.route decorators in front of a single function? Is the >> recommended way to handle this in the web server configuration instead? >> >> >> -- >> Alex Hall >> Automatic Distributors, IT department >> ahall at autodist.com >> >> _______________________________________________ >> Flask mailing list >> Flask at python.org >> https://mail.python.org/mailman/listinfo/flask >> >> > -- Alex Hall Automatic Distributors, IT department ahall at autodist.com -------------- next part -------------- An HTML attachment was scrubbed... URL: From ford.anthonyj at gmail.com Wed May 11 09:43:40 2016 From: ford.anthonyj at gmail.com (Anthony Ford) Date: Wed, 11 May 2016 08:43:40 -0500 Subject: [Flask] "could not build URL for endpoint"? In-Reply-To: References: Message-ID: If you're not using blueprints, leave it off (see http://flask.pocoo.org/docs/0.10/blueprints/#building-urls). I'm not sure if it will cause problems if you aren't using blueprints, or if it will just ignore it. In a blueprint, it tells werkzueg to use the current blueprint as the source of handler functions, instead of the global pool. If you don't use the leading period and have a function name crash (i.e. index in your admin blueprint and index in your public blueprint), it won't know which one to use (or may choose incorrectly). You can also specify blueprints if you need to reach across blueprints (i.e. have a link to the login page within your admin blueprint) , by specifying the blueprint name (say "admin.login"). Anthony Ford, KF5IBN, ford.anthonyj at gmail.com On Wed, May 11, 2016 at 8:36 AM, Alex Hall wrote: > Okay, thanks--that explains a lot! I had a function called 'index', but > moved my decorators for / and /index off of it. I didn't realize url_for > worked that way, so I was calling a function that had no app.route > decorators. This explains so much. > > Your example said to use url_for('.foobar')}}. Was the period supposed to > be before the function name, or was that a typo? Just want to make sure > there's not some other aspect I'm missing. Thanks. > > On Wed, May 11, 2016 at 9:32 AM, Anthony Ford > wrote: > >> Your running into an uissue in that url_for doesn't take the path ( the >> "/foo/bar" in "example.com/foo/bar") but the function which provides the >> view you want. >> >> If you define a route (say "/index"), and the function that handles that >> route is foobar(), then you would use url_for('foobar'). >> >> So for: >> >> @app.route('/index') >> def foobar(): >> return render_template('foobar.html') >> >> >> your template would have the following link: >> >> a href="{{url_for('.foobar')}}">Home> >> >> Hope that helps! >> >> Also, be careful with your quotes. While Jinja should pick up the quotes >> within {{}} and handle them well, even with the outer quotes, it's good to >> be in the habit of not mixing quotes. Use one type (i.e. double) for your >> outer, and the other (single) for your inner. Since Python doesn't >> differentiate between the types, it's safe to swap them as you desire. >> >> >> >> Anthony Ford, >> KF5IBN, >> ford.anthonyj at gmail.com >> >> On Wed, May 11, 2016 at 8:22 AM, Alex Hall wrote: >> >>> Hello list, >>> I have no idea what I changed--I've been messing with so many config >>> files and apps lately--but suddenly I'm getting that error when I load my >>> app. My templates use the 'url_for' function, as I'm told they should, but >>> that seems to be failing for some reason. The only related change I can >>> think of is that I recently added a couple more decorators to a view >>> function, in an effort to always direct to a certain view when visitors go >>> to the main site. That is >>> myapp.mysite.com/search >>> is redirected to by >>> myapp.mysite.com >>> or >>> myapp.mysite.com/index >>> >>> The error is "could not build URL for endpoint '/index'. Did you mean >>> '/search' instead? >>> >>> In my base template, I define a navigation bar. In the exception, the >>> first url in that bar is causing the problem: >>> a href="{{url_for("/index")}}">Home>> >>> Might the problem be that I'm defining a link (/index) that will render >>> as this view, because that's a decorator before the /search function? That >>> doesn't make much sense to me, but I can't think what else it could be. >>> Related: is there a better way of directing to a certain view than putting >>> a bunch of app.route decorators in front of a single function? Is the >>> recommended way to handle this in the web server configuration instead? >>> >>> >>> -- >>> Alex Hall >>> Automatic Distributors, IT department >>> ahall at autodist.com >>> >>> _______________________________________________ >>> Flask mailing list >>> Flask at python.org >>> https://mail.python.org/mailman/listinfo/flask >>> >>> >> > > > -- > Alex Hall > Automatic Distributors, IT department > ahall at autodist.com > -------------- next part -------------- An HTML attachment was scrubbed... URL: From 451517996 at qq.com Thu May 12 01:45:36 2016 From: 451517996 at qq.com (=?gb18030?B?zuLD+g==?=) Date: Thu, 12 May 2016 13:45:36 +0800 Subject: [Flask] a open source twitter Message-ID: http://abelkhan.com build a open source twitter by flask now it is a demo reception every one join my repository btw github:https://github.com/qianqians/abelkhan.git -------------- next part -------------- An HTML attachment was scrubbed... URL: From jwheeler1 at gmail.com Thu May 12 11:11:52 2016 From: jwheeler1 at gmail.com (John Wheeler) Date: Thu, 12 May 2016 08:11:52 -0700 Subject: [Flask] Flask-Ask a Flask Extension for Writing Amazon Echo Apps with Alexa Skills Kit Message-ID: Hello everybody out there, I've been working on a Flask extension, called Flask-Ask, for programming Alexa skills on the Amazon Echo. I've been working on this for a few weeks now and have a release pushed up to pypi, samples, and documentation. The Alexa service is based on its own request / response model that uses JSON over HTTP. I made Flask-Ask's API similar to Flask's in that regard with routing / parameter mapping, context locals, and integration with Flask's template system. The code and samples are available at https://github.com/johnwheeler/flask-ask The documentation is here http://flask-ask.readthedocs.io/en/latest/ I'd like to know what people think of the API and what features they want. I'm working on a tutorial that shows how to rapidly develop skills with Flask-Ask and ngrok.io, and I'm available for a Google Hangout if you want to try and need help in the interim. John -------------- next part -------------- An HTML attachment was scrubbed... URL: From david at davidbaumgold.com Thu May 12 11:29:45 2016 From: david at davidbaumgold.com (David Baumgold) Date: Thu, 12 May 2016 11:29:45 -0400 Subject: [Flask] Flask-Ask a Flask Extension for Writing Amazon Echo Apps with Alexa Skills Kit In-Reply-To: References: Message-ID: Hey John, this looks nifty! However, I have a few comments for how it can be improved: * You should use the ?cryptography? module instead of PyOpenSSL:?https://cryptography.io * None of your classes or methods have docstrings! I suggest writing docstrings, and using Sphinx?s autodoc extension to render those docstrings in your documentation:?http://www.sphinx-doc.org/en/stable/ext/autodoc.html? * What if I don?t want to use YAML? I suggest removing that dependency, and exposing an API to fetch a template. That way, the developer can put multiple templates in one YAML file the way you have it set up, but it?s not required, and if the developer doesn?t use YAML then it won?t be pulled in as a dependency. * ASK_VERIFY_TIMESTAMP is set to False by default, but it?s generally good practice to make code secure by default. That way, a developer can intentionally and knowingly change the defaults to be insecure for development purposes, but is less likely to leave them insecure in production. * Rather than setting a default ASK_ROUTE setting, why not construct this as a Flask Blueprint, so the developer can attach it to whatever URL he/she wants? Let me know if you?d like me to clarify some of these points. In spite of my comments, I think this is a really nifty idea, and I might want to try using it sometime! David Baumgold On May 12, 2016 at 11:12:41 AM, John Wheeler (jwheeler1 at gmail.com) wrote: Hello everybody out there, I've been working on a Flask extension, called Flask-Ask, for programming Alexa skills on the Amazon Echo. I've been working on this for a few weeks now and have a release pushed up to pypi, samples, and documentation. The Alexa service is based on its own request / response model that uses JSON over HTTP. I made Flask-Ask's API similar to Flask's in that regard with routing / parameter mapping, context locals, and integration with Flask's template system. The code and samples are available at https://github.com/johnwheeler/flask-ask The documentation is here http://flask-ask.readthedocs.io/en/latest/ I'd like to know what people think of the API and what features they want. I'm working on a tutorial that shows how to rapidly develop skills with Flask-Ask and ngrok.io, and I'm available for a Google Hangout if you want to try and need help in the interim. John _______________________________________________ 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 Thu May 12 11:35:16 2016 From: david at davidbaumgold.com (David Baumgold) Date: Thu, 12 May 2016 11:35:16 -0400 Subject: [Flask] Flask-Ask a Flask Extension for Writing Amazon Echo Apps with Alexa Skills Kit In-Reply-To: References: Message-ID: Oh, one more very important thing: where are the automated tests?! On May 12, 2016 at 11:29:49 AM, David Baumgold (david at davidbaumgold.com) wrote: Hey John, this looks nifty! However, I have a few comments for how it can be improved: * You should use the ?cryptography? module instead of PyOpenSSL:?https://cryptography.io * None of your classes or methods have docstrings! I suggest writing docstrings, and using Sphinx?s autodoc extension to render those docstrings in your documentation:?http://www.sphinx-doc.org/en/stable/ext/autodoc.html? * What if I don?t want to use YAML? I suggest removing that dependency, and exposing an API to fetch a template. That way, the developer can put multiple templates in one YAML file the way you have it set up, but it?s not required, and if the developer doesn?t use YAML then it won?t be pulled in as a dependency. * ASK_VERIFY_TIMESTAMP is set to False by default, but it?s generally good practice to make code secure by default. That way, a developer can intentionally and knowingly change the defaults to be insecure for development purposes, but is less likely to leave them insecure in production. * Rather than setting a default ASK_ROUTE setting, why not construct this as a Flask Blueprint, so the developer can attach it to whatever URL he/she wants? Let me know if you?d like me to clarify some of these points. In spite of my comments, I think this is a really nifty idea, and I might want to try using it sometime! David Baumgold On May 12, 2016 at 11:12:41 AM, John Wheeler (jwheeler1 at gmail.com) wrote: Hello everybody out there, I've been working on a Flask extension, called Flask-Ask, for programming Alexa skills on the Amazon Echo. I've been working on this for a few weeks now and have a release pushed up to pypi, samples, and documentation. The Alexa service is based on its own request / response model that uses JSON over HTTP. I made Flask-Ask's API similar to Flask's in that regard with routing / parameter mapping, context locals, and integration with Flask's template system. The code and samples are available at https://github.com/johnwheeler/flask-ask The documentation is here http://flask-ask.readthedocs.io/en/latest/ I'd like to know what people think of the API and what features they want. I'm working on a tutorial that shows how to rapidly develop skills with Flask-Ask and ngrok.io, and I'm available for a Google Hangout if you want to try and need help in the interim. John _______________________________________________ Flask mailing list Flask at python.org https://mail.python.org/mailman/listinfo/flask -------------- next part -------------- An HTML attachment was scrubbed... URL: From jwheeler1 at gmail.com Thu May 12 13:29:07 2016 From: jwheeler1 at gmail.com (John Wheeler) Date: Thu, 12 May 2016 10:29:07 -0700 Subject: [Flask] Flask-Ask a Flask Extension for Writing Amazon Echo Apps with Alexa Skills Kit In-Reply-To: References: Message-ID: David, Whoa! Thank you man! We're on the same page with a lot of these. I'm going to check out the cryptography module. I hadn't heard of it, but I want to see it. The docstrings / autodoc are a priority. This is my first time using Sphinx, and I prioritized shipping *something* with minimal docs, but now I'm switching gears and working on a tutorial / more comprehensive docs. If was pulling the library down, and I saw the PyYAML dependency, it would cause me to pause. What's important to me now is showcasing the feature of grouping templates in a single file vs per file templates. At first, I started rolling my own system sort of based on Lektor content files but then decided to grab YAML off the shelf because I couldn't think of any hard reasons aside from the dependency not to. But I don't like the dependency and also want to work toward removing it. For the timestamp verification, your clock needs to sync with the NTP, so I did this to lower barriers to entry. The security concern didn't escape me either though. What would your thoughts be on turning timestamp (any, all) verification off when app.debug = True? I'll investigate blueprints further--I have not looked at them much. Other APIs that reserve a default URL put an underscore in front to mitigate against clobbering. A lot of Google App Engine APIs work like that. I don't think it's ideal, but don't know if shifting over to a blueprint is worth it. Excuse my ignorance on blueprints for the time-being. Where are those tests, David? :-) In all seriousness, they are something that I need and want to do, but have back burnered for now in favor developing against the samples (which have been ported from the official Amazon Java skills kit). Thank you again David, hope to hear more from you. On Thu, May 12, 2016 at 8:35 AM, David Baumgold wrote: > Oh, one more very important thing: where are the automated tests?! > > On May 12, 2016 at 11:29:49 AM, David Baumgold (david at davidbaumgold.com) > wrote: > > Hey John, this looks nifty! However, I have a few comments for how it can > be improved: > > * You should use the ?cryptography? module instead of PyOpenSSL: > https://cryptography.io > * None of your classes or methods have docstrings! I suggest writing > docstrings, and using Sphinx?s autodoc extension to render those docstrings > in your documentation: > http://www.sphinx-doc.org/en/stable/ext/autodoc.html > * What if I don?t want to use YAML? I suggest removing that dependency, > and exposing an API to fetch a template. That way, the developer can put > multiple templates in one YAML file the way you have it set up, but it?s > not required, and if the developer doesn?t use YAML then it won?t be pulled > in as a dependency. > * ASK_VERIFY_TIMESTAMP is set to False by default, but it?s generally good > practice to make code secure by default. That way, a developer can > intentionally and knowingly change the defaults to be insecure for > development purposes, but is less likely to leave them insecure in > production. > * Rather than setting a default ASK_ROUTE setting, why not construct this > as a Flask Blueprint, so the developer can attach it to whatever URL he/she > wants? > > Let me know if you?d like me to clarify some of these points. In spite of > my comments, I think this is a really nifty idea, and I might want to try > using it sometime! > > David Baumgold > > On May 12, 2016 at 11:12:41 AM, John Wheeler (jwheeler1 at gmail.com) wrote: > > Hello everybody out there, > > I've been working on a Flask extension, called Flask-Ask, for programming > Alexa skills on the Amazon Echo. I've been working on this for a few weeks > now and have a release pushed up to pypi, samples, and documentation. > > The Alexa service is based on its own request / response model that uses > JSON over HTTP. I made Flask-Ask's API similar to Flask's in that regard > with routing / parameter mapping, context locals, and integration with > Flask's template system. > > The code and samples are available at > > https://github.com/johnwheeler/flask-ask > > The documentation is here > > http://flask-ask.readthedocs.io/en/latest/ > > I'd like to know what people think of the API and what features they want. > I'm working on a tutorial that shows how to rapidly develop skills with > Flask-Ask and ngrok.io, and I'm available for a Google Hangout if you > want to try and need help in the interim. > > John > _______________________________________________ > Flask mailing list > Flask at python.org > https://mail.python.org/mailman/listinfo/flask > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From jwheeler1 at gmail.com Thu May 12 12:26:50 2016 From: jwheeler1 at gmail.com (John Wheeler) Date: Thu, 12 May 2016 09:26:50 -0700 Subject: [Flask] Flask-Ask a Flask Extension for Writing Amazon Echo Apps with Alexa Skills Kit In-Reply-To: References: Message-ID: David, Whoa! Thank you man! We're on the same page with a lot of these. I'm going to check out the cryptography module. I hadn't heard of it, but I want to see it. The docstrings / autodoc are a priority. This is my first time using Sphinx, and I prioritized shipping *something* with minimal docs, but now I'm switching gears and working on a tutorial / more comprehensive docs. If was pulling the library down, and I saw the PyYAML dependency, it would cause me to pause. What's important to me now is showcasing the feature of grouping templates in a single file vs per file templates. At first, I started rolling my own system sort of based on Lektor content files but then decided to grab YAML off the shelf because I couldn't think of any hard reasons aside from the dependency not to. But I don't like the dependency and also want to work toward removing it. For the timestamp verification, your clock needs to sync with the NTP, so I did this to lower barriers to entry. The security concern didn't escape me either though. What would your thoughts be on turning timestamp (any, all) verification off when app.debug = True? I'll investigate blueprints further--I have not looked at them much. Other APIs that reserve a default URL put an underscore in front to mitigate against clobbering. A lot of Google App Engine APIs work like that. I don't think it's ideal, but don't know if shifting over to a blueprint is worth it. Excuse my ignorance on blueprints for the time-being. Where are those tests, David? :-) In all seriousness, they are something that I need and want to do, but have back burnered for now in favor developing against the samples (which have been ported from the official Amazon Java skills kit). Thank you again David, hope to hear more from you. John On Thu, May 12, 2016 at 8:35 AM, David Baumgold wrote: > Oh, one more very important thing: where are the automated tests?! > > On May 12, 2016 at 11:29:49 AM, David Baumgold (david at davidbaumgold.com) > wrote: > > Hey John, this looks nifty! However, I have a few comments for how it can > be improved: > > * You should use the ?cryptography? module instead of PyOpenSSL: > https://cryptography.io > * None of your classes or methods have docstrings! I suggest writing > docstrings, and using Sphinx?s autodoc extension to render those docstrings > in your documentation: > http://www.sphinx-doc.org/en/stable/ext/autodoc.html > * What if I don?t want to use YAML? I suggest removing that dependency, > and exposing an API to fetch a template. That way, the developer can put > multiple templates in one YAML file the way you have it set up, but it?s > not required, and if the developer doesn?t use YAML then it won?t be pulled > in as a dependency. > * ASK_VERIFY_TIMESTAMP is set to False by default, but it?s generally good > practice to make code secure by default. That way, a developer can > intentionally and knowingly change the defaults to be insecure for > development purposes, but is less likely to leave them insecure in > production. > * Rather than setting a default ASK_ROUTE setting, why not construct this > as a Flask Blueprint, so the developer can attach it to whatever URL he/she > wants? > > Let me know if you?d like me to clarify some of these points. In spite of > my comments, I think this is a really nifty idea, and I might want to try > using it sometime! > > David Baumgold > > On May 12, 2016 at 11:12:41 AM, John Wheeler (jwheeler1 at gmail.com) wrote: > > Hello everybody out there, > > I've been working on a Flask extension, called Flask-Ask, for programming > Alexa skills on the Amazon Echo. I've been working on this for a few weeks > now and have a release pushed up to pypi, samples, and documentation. > > The Alexa service is based on its own request / response model that uses > JSON over HTTP. I made Flask-Ask's API similar to Flask's in that regard > with routing / parameter mapping, context locals, and integration with > Flask's template system. > > The code and samples are available at > > https://github.com/johnwheeler/flask-ask > > The documentation is here > > http://flask-ask.readthedocs.io/en/latest/ > > I'd like to know what people think of the API and what features they want. > I'm working on a tutorial that shows how to rapidly develop skills with > Flask-Ask and ngrok.io, and I'm available for a Google Hangout if you > want to try and need help in the interim. > > John > _______________________________________________ > Flask mailing list > Flask at python.org > https://mail.python.org/mailman/listinfo/flask > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From zufaellig at outlook.com Sat May 14 22:30:17 2016 From: zufaellig at outlook.com (Patrick Rieser) Date: Sun, 15 May 2016 02:30:17 +0000 Subject: [Flask] Add, Change and Delete Models during runtime with flask-sqlalchemy and flask-migrate Message-ID: Hello everybody, so I try to add, change and delete Models during runtime with flask-sqlalchemy and flask-migrate . To do that I plan to write/change/delete the mymodel.py file, create the migration script and then do the migration. So far so good. The problem is that I don't know what internally happens in Flask and flask-sqlalchemy. I guess that there is at least some internal caching/dict to store additional information (like class names, fields etc.) that should be added/changed/cleared accordingly. Does anybody have any clue about this? Any help is greatly appreciated! With kind regards, Patrick -------------- next part -------------- An HTML attachment was scrubbed... URL: From alejoar at gmail.com Sun May 15 04:58:40 2016 From: alejoar at gmail.com (Alejo Arias) Date: Sun, 15 May 2016 10:58:40 +0200 Subject: [Flask] Add, Change and Delete Models during runtime with flask-sqlalchemy and flask-migrate In-Reply-To: References: Message-ID: If you change the models you are basically changing the app code. I don't think this would be possible, a restart is needed at some point to acknowledge the new models. Even if you do the changes directly in the DB, you'll start getting exceptions when the app tries to do stuff with things that no longer exist in your new models. What's the purpose of this? On May 15, 2016 04:31, "Patrick Rieser" wrote: Hello everybody, so I try to add, change and delete Models during runtime with flask-sqlalchemy and flask-migrate . To do that I plan to write/change/delete the mymodel.py file, create the migration script and then do the migration. So far so good. The problem is that I don't know what internally happens in Flask and flask-sqlalchemy. I guess that there is at least some internal caching/dict to store additional information (like class names, fields etc.) that should be added/changed/cleared accordingly. Does anybody have any clue about this? Any help is greatly appreciated! With kind regards, Patrick _______________________________________________ Flask mailing list Flask at python.org https://mail.python.org/mailman/listinfo/flask -------------- next part -------------- An HTML attachment was scrubbed... URL: From zufaellig at outlook.com Sun May 15 16:45:44 2016 From: zufaellig at outlook.com (Patrick Rieser) Date: Sun, 15 May 2016 20:45:44 +0000 Subject: [Flask] Add, Change and Delete Models during runtime with flask-sqlalchemy and flask-migrate Message-ID: The purpose of this is that it would be possible then to serve multiple customers whose frontend overlaps mostly (the rest would be hidden behind feature locks), but where the table layout differs significantly from, a single application. "I don't think this would be possible, a restart is needed at some point to acknowledge the new models. Even if you do the changes directly in the DB, you'll start getting exceptions when the app tries to do stuff with things that no longer exist in your new models."The way I understand it (please correct me if I am wrong) is that the mapper in SQLAlchemy takes the module declaration and mapps it to a table which is stored at the metadata instance. So the plan would be to use manual mapping when a new table is created at runtime and to use metadata.remove to remove the table object from sqlalchemy.I think that one should in theory even be able to use the Table class from sqlalchemy core to define and register tables in as well as use metadata.remove to remove them on the fly and use alembic to do the changes in the database. But I have absolutely no clue if I would be able to still use flask-sqlalchemy which is no hard requirement, but makes thinks a lot easier.The problem is this goes way beyond my knowledge of flask-sqlalchmy (which as far as I know only wraps and extends sqlalchemy) and sqlalchemy in general, so I was looking for some pointers or help.Best wishes,PatrickDate: Sun, 15 May 2016 10:58:40 +0200Subject: Re: [Flask] Add, Change and Delete Models during runtime with flask-sqlalchemy and flask-migrateFrom: alejoar at gmail.comTo: zufaellig at outlook.comCC: flask at python.orgIf you change the models you are basically changing the app code.I don't think this would be possible, a restart is needed at some point to acknowledge the new models. Even if you do the changes directly in the DB, you'll start getting exceptions when the app tries to do stuff with things that no longer exist in your new models. What's the purpose of this? On May 15, 2016 04:31, "Patrick Rieser" wrote:Hello everybody, so I try to add, change and delete Models during runtime with flask-sqlalchemy and flask-migrate . To do that I plan to write/change/delete the mymodel.py file, create the migration script and then do the migration. So far so good. The problem is that I don't know what internally happens in Flask and flask-sqlalchemy. I guess that there is at least some internal caching/dict to store additional information (like class names, fields etc.) that should be added/changed/cleared accordingly. Does anybody have any clue about this? Any help is greatly appreciated! With kind regards,Patrick_______________________________________________Flask mailing listFlask at python.orghttps://mail.python.org/mailman/listinfo/flask -------------- next part -------------- An HTML attachment was scrubbed... URL: From ford.anthonyj at gmail.com Mon May 16 11:17:55 2016 From: ford.anthonyj at gmail.com (Anthony Ford) Date: Mon, 16 May 2016 10:17:55 -0500 Subject: [Flask] Add, Change and Delete Models during runtime with flask-sqlalchemy and flask-migrate In-Reply-To: References: Message-ID: Would it not make more sense to run these as separate blueprints/apps? Dispatch to the appropriate blueprint and DB/model once logged in? That seems like it would work for your application, and would require minimal re-writing/modding of the existing Flask/SQLAlchemy packages. Anthony Ford, KF5IBN, ford.anthonyj at gmail.com On Sun, May 15, 2016 at 3:45 PM, Patrick Rieser wrote: > The purpose of this is that it would be possible then to serve multiple > customers whose frontend overlaps mostly (the rest would be hidden behind > feature locks), but where the table layout differs significantly from, a > single application. > > "I don't think this would be possible, a restart is needed at some point > to acknowledge the new models. Even if you do the changes directly in the > DB, you'll start getting exceptions when the app tries to do stuff with > things that no longer exist in your new models." > > > The way I understand it (please correct me if I am wrong) is that the > mapper in SQLAlchemy takes the module declaration and mapps it to a table > which is stored at the metadata instance. So the plan would be to use > manual mapping when a new table is created at runtime and to use > metadata.remove to remove the table object from sqlalchemy. > > I think that one should in theory even be able to use the Table class from > sqlalchemy core to define and register tables in as well as use > metadata.remove to remove them on the fly and use alembic to do the changes > in the database. But I have absolutely no clue if I would be able to still > use flask-sqlalchemy which is no hard requirement, but makes thinks a lot > easier. > > The problem is this goes way beyond my knowledge of flask-sqlalchmy (which > as far as I know only wraps and extends sqlalchemy) and sqlalchemy in > general, so I was looking for some pointers or help. > > > Best wishes, > Patrick > > > > ------------------------------ > Date: Sun, 15 May 2016 10:58:40 +0200 > Subject: Re: [Flask] Add, Change and Delete Models during runtime with > flask-sqlalchemy and flask-migrate > From: alejoar at gmail.com > To: zufaellig at outlook.com > CC: flask at python.org > > > If you change the models you are basically changing the app code. > > I don't think this would be possible, a restart is needed at some point to > acknowledge the new models. Even if you do the changes directly in the DB, > you'll start getting exceptions when the app tries to do stuff with things > that no longer exist in your new models. > > What's the purpose of this? > On May 15, 2016 04:31, "Patrick Rieser" wrote: > > Hello everybody, > > so I try to add, change and delete Models during runtime with > flask-sqlalchemy and flask-migrate . To do that I plan to > write/change/delete the mymodel.py file, create the migration script and > then do the migration. So far so good. The problem is that I don't know > what internally happens in Flask and flask-sqlalchemy. I guess that there > is at least some internal caching/dict to store additional information > (like class names, fields etc.) that should be added/changed/cleared > accordingly. Does anybody have any clue about this? Any help is greatly > appreciated! > > > With kind regards, > Patrick > > _______________________________________________ > 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 and.damore at gmail.com Mon May 16 13:28:43 2016 From: and.damore at gmail.com (Andrea D'Amore) Date: Mon, 16 May 2016 19:28:43 +0200 Subject: [Flask] Add, Change and Delete Models during runtime with flask-sqlalchemy and flask-migrate In-Reply-To: References: Message-ID: > On Sun, May 15, 2016 at 3:45 PM, Patrick Rieser > wrote: >> The purpose of this is that it would be possible then to serve multiple >> customers whose frontend overlaps mostly (the rest would be hidden behind >> feature locks), but where the table layout differs significantly from, a >> single application. On 16 May 2016 at 17:17, Anthony Ford wrote: > Would it not make more sense to run these as separate blueprints/apps? > Dispatch to the appropriate blueprint and DB/model once logged in? That's what sound reasonable from the need presented there. > That seems like it would work for your application, and would require > minimal re-writing/modding of the existing Flask/SQLAlchemy packages. I'm still failing to see where that on-the-fly mapping chang is needed, i.e. why not just restarting the app. Is it something done to gain a more insightful understanding of the various components? -- Andrea From matt at mattshields.org Wed May 18 09:48:32 2016 From: matt at mattshields.org (Matt Shields) Date: Wed, 18 May 2016 09:48:32 -0400 Subject: [Flask] Uploading image into MySQL Blob Message-ID: I'm trying to get an image uploaded through a form and inserted into a Blob field in MySQL. This doesn't seem to work. What's wrong? clientid = request.form['clientid'] file = request.files['logo'] path = config.app_path() filename = "%s-logo.png" % clientid local_file = "%s/static/%s" % (path, filename) file.save(local_file) sql = "UPDATE client SET logo = LOAD_FILE('%s') WHERE clientid = '%s'" % (local_file, clientid) dbQuery(sql) #This is custom function to run a sql query. Matt -------------- next part -------------- An HTML attachment was scrubbed... URL: From giannis.pin at gmail.com Wed May 18 11:30:48 2016 From: giannis.pin at gmail.com (Ioannis Pinakoulakis) Date: Wed, 18 May 2016 17:30:48 +0200 Subject: [Flask] Uploading image into MySQL Blob In-Reply-To: References: Message-ID: <44AE6AF3-93E1-48F1-B9FA-9A42BC974641@gmail.com> Hi Matt, Firstly, I would like to mention that a better approach would be to not store the image in the database, rather a link that points to the each image probably in the file system. This will speed up your application, since 1) you query the database for less data, 2) reading from the file system is faster and finally 3) in case you want to move the images on a CDN or in general serve them from a separate server then this does not block you. Thus easier migrations. Back to your original problem. Do you get any error or something? Ioannis 18 maj 2016, 15:48, ?/? Matt Shields ??????: > I'm trying to get an image uploaded through a form and inserted into a Blob field in MySQL. This doesn't seem to work. What's wrong? > > clientid = request.form['clientid'] > file = request.files['logo'] > path = config.app_path() > filename = "%s-logo.png" % clientid > local_file = "%s/static/%s" % (path, filename) > file.save(local_file) > sql = "UPDATE client SET logo = LOAD_FILE('%s') WHERE clientid = '%s'" % (local_file, clientid) > dbQuery(sql) #This is custom function to run a sql query. > > Matt > _______________________________________________ > Flask mailing list > Flask at python.org > https://mail.python.org/mailman/listinfo/flask From matt at mattshields.org Wed May 18 11:58:39 2016 From: matt at mattshields.org (Matt Shields) Date: Wed, 18 May 2016 11:58:39 -0400 Subject: [Flask] Uploading image into MySQL Blob In-Reply-To: <44AE6AF3-93E1-48F1-B9FA-9A42BC974641@gmail.com> References: <44AE6AF3-93E1-48F1-B9FA-9A42BC974641@gmail.com> Message-ID: Actually, disregard my question. I ended up using a AWS S3 bucket to host the images. I was able to convert the code in a matter of minutes, compared to the 2 days I wasted trying to get images uploaded into MySQL. Matt On Wed, May 18, 2016 at 11:30 AM, Ioannis Pinakoulakis < giannis.pin at gmail.com> wrote: > Hi Matt, > > Firstly, I would like to mention that a better approach would be to not > store the image in the database, rather a link that points to the each > image probably in the file system. This will speed up your application, > since 1) you query the database for less data, 2) reading from the file > system is faster and finally 3) in case you want to move the images on a > CDN or in general serve them from a separate server then this does not > block you. Thus easier migrations. > > Back to your original problem. Do you get any error or something? > > Ioannis > > 18 maj 2016, 15:48, ?/? Matt Shields ??????: > > > I'm trying to get an image uploaded through a form and inserted into a > Blob field in MySQL. This doesn't seem to work. What's wrong? > > > > clientid = request.form['clientid'] > > file = request.files['logo'] > > path = config.app_path() > > filename = "%s-logo.png" % clientid > > local_file = "%s/static/%s" % (path, filename) > > file.save(local_file) > > sql = "UPDATE client SET logo = LOAD_FILE('%s') WHERE clientid = '%s'" % > (local_file, clientid) > > dbQuery(sql) #This is custom function to run a sql query. > > > > Matt > > _______________________________________________ > > Flask mailing list > > Flask at python.org > > https://mail.python.org/mailman/listinfo/flask > -------------- next part -------------- An HTML attachment was scrubbed... URL: From ahall at autodist.com Thu May 19 14:04:13 2016 From: ahall at autodist.com (Alex Hall) Date: Thu, 19 May 2016 14:04:13 -0400 Subject: [Flask] Default/Disabled choices in WTForms SelectField? Message-ID: Hi all, This is perhaps more of a WTForms question, but I'm hoping people here will know how to do this in Flask-WTF. I have three select lists, and until the user clicks them, they're all blank. I want to have them each show an unselectable option to indicate that they exist, something like option value="1" default disabled>Please choose an option wrote: > Hi all, > This is perhaps more of a WTForms question, but I'm hoping people here > will know how to do this in Flask-WTF. > > I have three select lists, and until the user clicks them, they're all > blank. I want to have them each show an unselectable option to indicate > that they exist, something like > option value="1" default disabled>Please choose an option > I can't find a way to do this in WTF though. I found one forum that said > you can pass a "default=" argument to the SelectField constructor, but I > don't see that in the official documentation. Plus, that doesn't tell me > how to make the same item disabled, or if what goes after the equals sign > is an index or an element in the choices list of values. > > Thanks for any suggestions. If this is doable, will it work the same way > on SelectMultipleField items as well? > > -- > Alex Hall > Automatic Distributors, IT department > ahall at autodist.com > > _______________________________________________ > Flask mailing list > Flask at python.org > https://mail.python.org/mailman/listinfo/flask > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From nik.gen at gmx.de Fri May 20 11:11:46 2016 From: nik.gen at gmx.de (Nikolaus Neusser) Date: Fri, 20 May 2016 17:11:46 +0200 Subject: [Flask] Interchange data with main python application Message-ID: <98a75866-31ac-1ec3-f4a5-1d1591f18575@gmx.de> Hi everyone, I'm using flask for the first time and after trying quite a lot, i still fail. :-( I am wondering what i am doing wrong and if flask is the right way to go at all. My objective: - I have a main python application, which basically is based on a PySide (QT4) event loop. This runs a bigger state machine and several other functions. - Now, i want to add a web interface which reads/sets parameters and displays a longer list of strings from the main application (variable length) . Where i am: - The simple flask examples from various tutorials work fine for me. - BUT: I cannot combine my main application with flask, i.e. i don't know how to interchange the data between my main application and the flask route-functions. What i tried: - running flask in a thread (QThread). Works fine for a simple example, i.e. deliver static html and react on get-request - run flask in main thread. Doesn't work since some of my functions rely on the qt event loop - interchanging data between my main application and flask in the thread. I tried this using the qt signal/slot mechanism. This doesn't work, because the signals which i have to define in the main application are not accessible within the flask route-functions. I really hope you can give me some good advice. I can post code snippets if it helps for clarification. Thanks a lot, Nik From ford.anthonyj at gmail.com Fri May 20 11:30:43 2016 From: ford.anthonyj at gmail.com (Anthony Ford) Date: Fri, 20 May 2016 10:30:43 -0500 Subject: [Flask] Interchange data with main python application In-Reply-To: <98a75866-31ac-1ec3-f4a5-1d1591f18575@gmx.de> References: <98a75866-31ac-1ec3-f4a5-1d1591f18575@gmx.de> Message-ID: My suggestion is to avoid running either within the other. If possible, try running each standalone. For inter process communication, try using socket communication, either with straight sockets or via something like zeromq or similar. --Ford On May 20, 2016 10:12 AM, "Nikolaus Neusser" wrote: > Hi everyone, > > I'm using flask for the first time and after trying quite a lot, i still > fail. :-( > I am wondering what i am doing wrong and if flask is the right way to go > at all. > > My objective: > - I have a main python application, which basically is based on a > PySide (QT4) event loop. > This runs a bigger state machine and several other functions. > - Now, i want to add a web interface which reads/sets parameters and > displays a longer list of > strings from the main application (variable length) . > > Where i am: > - The simple flask examples from various tutorials work fine for me. > - BUT: I cannot combine my main application with flask, i.e. i don't > know how to > interchange the data between my main application and the flask > route-functions. > > What i tried: > - running flask in a thread (QThread). Works fine for a simple example, > i.e. deliver static html > and react on get-request > - run flask in main thread. Doesn't work since some of my functions > rely on the qt event loop > - interchanging data between my main application and flask in the > thread. I tried this using the > qt signal/slot mechanism. > This doesn't work, because the signals which i have to define in the > main application are not > accessible within the flask route-functions. > > > I really hope you can give me some good advice. > I can post code snippets if it helps for clarification. > > Thanks a lot, > > Nik > _______________________________________________ > Flask mailing list > Flask at python.org > https://mail.python.org/mailman/listinfo/flask > -------------- next part -------------- An HTML attachment was scrubbed... URL: From vasudev at copyninja.info Sun May 22 06:18:21 2016 From: vasudev at copyninja.info (Vasudev Kamath) Date: Sun, 22 May 2016 15:48:21 +0530 Subject: [Flask] Unable to access backend application with DispatcherMiddleware deployment Message-ID: <871t4u9z0y.fsf@rudra.copyninja.info> Hello, I've an application ? which uses "Combining application" deployment as mentioned in Flask documentation here ?. Application itself is written as per ?. I'm actually deploying 2 application one is frontend which is main app and another backend app for serving API at /api ?. API application has jsonrpc app which is exposed at /api/JSONRPC. Both frontend and API uses Blueprints to add routing rules. API part uses a custom decorator to register route for blueprint ? ?. After creating app for api part I can see /api/JSONRPC registered in the `url_map` but when I hit /api/JSONRPC I get 404 error. I'm unable to figure out why this is happening. Can any one help me figure out what is causing 404 errors?. I did try Google and also posted on Stack Overflow? but didn't get any solution yet. ? https://github.com/libindic/Silpa-Flask/tree/development ? http://flask.pocoo.org/docs/0.10/patterns/appdispatch/#combining-applications ? http://mattupstate.com/blog/how-i-structure-my-flask-applications/ ? https://github.com/libindic/Silpa-Flask/blob/development/wsgi.py ? https://github.com/libindic/Silpa-Flask/blob/development/silpa/api/__init__.py#L6 ? https://github.com/libindic/Silpa-Flask/blob/development/silpa/api/jsonrpc.py#L27 ? http://stackoverflow.com/questions/37241098/combining-2-flask-apps-using-dispatchermiddleware-instance-results-in-404-for-se Thanks and Regards, -- Vasudev From colin at techdata.net.au Sun May 22 22:07:25 2016 From: colin at techdata.net.au (Colin Haig) Date: Mon, 23 May 2016 10:07:25 +0800 Subject: [Flask] SSL Apache Message-ID: <6B7B4B5C-1CC5-4845-8A28-B0440EA1956A@techdata.net.au> Hi All I have a small flask app running on apache 2.4 on windows using HTTP but have problems with my virtual hosts entry file when trying load apache with SSL ? if I comment out my virtual hosts file in http.conf I can start apache with http.exe ?D SSL but if I uncomment my virtual host include in http.conf I can start apache with http.exe ?D SSL Any help appreciated. Regards Colin -------------- next part -------------- An HTML attachment was scrubbed... URL: From nik.gen at gmx.de Mon May 23 17:02:08 2016 From: nik.gen at gmx.de (Nikolaus Neusser) Date: Mon, 23 May 2016 23:02:08 +0200 Subject: [Flask] Interchange data with main python application In-Reply-To: References: <98a75866-31ac-1ec3-f4a5-1d1591f18575@gmx.de> Message-ID: <8ddf37a3-d54f-982a-8e7b-910fee0045ae@gmx.de> >For inter process communication, try using socket communication, either with straight sockets or via something like zeromq or similar. I think, that's the problem i have. Either way of inter process communication needs some kind of event loop. Flask runs its own event loop, right? So, how do i mix these two? Nik Am 20.05.2016 um 17:30 schrieb Anthony Ford: > > My suggestion is to avoid running either within the other. If possible, try running each standalone. For inter > process communication, try using socket communication, either with straight sockets or via something like zeromq > or similar. > > --Ford > > On May 20, 2016 10:12 AM, "Nikolaus Neusser" > wrote: > > Hi everyone, > > I'm using flask for the first time and after trying quite a lot, i still fail. :-( > I am wondering what i am doing wrong and if flask is the right way to go at all. > > My objective: > - I have a main python application, which basically is based on a PySide (QT4) event loop. > This runs a bigger state machine and several other functions. > - Now, i want to add a web interface which reads/sets parameters and displays a longer list of > strings from the main application (variable length) . > > Where i am: > - The simple flask examples from various tutorials work fine for me. > - BUT: I cannot combine my main application with flask, i.e. i don't know how to > interchange the data between my main application and the flask route-functions. > > What i tried: > - running flask in a thread (QThread). Works fine for a simple example, i.e. deliver static html > and react on get-request > - run flask in main thread. Doesn't work since some of my functions rely on the qt event loop > - interchanging data between my main application and flask in the thread. I tried this using the > qt signal/slot mechanism. > This doesn't work, because the signals which i have to define in the main application are not > accessible within the flask route-functions. > > > I really hope you can give me some good advice. > I can post code snippets if it helps for clarification. > > Thanks a lot, > > Nik > _______________________________________________ > Flask mailing list > Flask at python.org > https://mail.python.org/mailman/listinfo/flask > -------------- next part -------------- An HTML attachment was scrubbed... URL: From coreybrett at gmail.com Mon May 23 17:34:24 2016 From: coreybrett at gmail.com (Corey Boyle) Date: Mon, 23 May 2016 17:34:24 -0400 Subject: [Flask] Interchange data with main python application In-Reply-To: <8ddf37a3-d54f-982a-8e7b-910fee0045ae@gmx.de> References: <98a75866-31ac-1ec3-f4a5-1d1591f18575@gmx.de> <8ddf37a3-d54f-982a-8e7b-910fee0045ae@gmx.de> Message-ID: Have each independent app store events in a common queue. Each app also watches for those events in the queue and processes them accordingly. Take a look at http://python-rq.org . On May 23, 2016 5:02 PM, "Nikolaus Neusser" wrote: > >For inter process communication, try using socket communication, either > with straight sockets or via something like zeromq or similar. > > I think, that's the problem i have. Either way of inter process > communication needs some kind of event loop. > Flask runs its own event loop, right? > So, how do i mix these two? > > Nik > > > Am 20.05.2016 um 17:30 schrieb Anthony Ford: > > My suggestion is to avoid running either within the other. If possible, > try running each standalone. For inter process communication, try using > socket communication, either with straight sockets or via something like > zeromq or similar. > > --Ford > On May 20, 2016 10:12 AM, "Nikolaus Neusser" wrote: > >> Hi everyone, >> >> I'm using flask for the first time and after trying quite a lot, i still >> fail. :-( >> I am wondering what i am doing wrong and if flask is the right way to go >> at all. >> >> My objective: >> - I have a main python application, which basically is based on a >> PySide (QT4) event loop. >> This runs a bigger state machine and several other functions. >> - Now, i want to add a web interface which reads/sets parameters and >> displays a longer list of >> strings from the main application (variable length) . >> >> Where i am: >> - The simple flask examples from various tutorials work fine for me. >> - BUT: I cannot combine my main application with flask, i.e. i don't >> know how to >> interchange the data between my main application and the flask >> route-functions. >> >> What i tried: >> - running flask in a thread (QThread). Works fine for a simple >> example, i.e. deliver static html >> and react on get-request >> - run flask in main thread. Doesn't work since some of my functions >> rely on the qt event loop >> - interchanging data between my main application and flask in the >> thread. I tried this using the >> qt signal/slot mechanism. >> This doesn't work, because the signals which i have to define in the >> main application are not >> accessible within the flask route-functions. >> >> >> I really hope you can give me some good advice. >> I can post code snippets if it helps for clarification. >> >> Thanks a lot, >> >> Nik >> _______________________________________________ >> 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 ford.anthonyj at gmail.com Mon May 23 22:11:19 2016 From: ford.anthonyj at gmail.com (Anthony Ford) Date: Mon, 23 May 2016 21:11:19 -0500 Subject: [Flask] Interchange data with main python application In-Reply-To: References: <98a75866-31ac-1ec3-f4a5-1d1591f18575@gmx.de> <8ddf37a3-d54f-982a-8e7b-910fee0045ae@gmx.de> Message-ID: I was gonna recommend python-rq, I just couldn't remember what it was called! Thanks for the link. Anthony Ford, KF5IBN, ford.anthonyj at gmail.com On Mon, May 23, 2016 at 4:34 PM, Corey Boyle wrote: > Have each independent app store events in a common queue. Each app also > watches for those events in the queue and processes them accordingly. Take > a look at http://python-rq.org . > On May 23, 2016 5:02 PM, "Nikolaus Neusser" wrote: > >> >For inter process communication, try using socket communication, either >> with straight sockets or via something like zeromq or similar. >> >> I think, that's the problem i have. Either way of inter process >> communication needs some kind of event loop. >> Flask runs its own event loop, right? >> So, how do i mix these two? >> >> Nik >> >> >> Am 20.05.2016 um 17:30 schrieb Anthony Ford: >> >> My suggestion is to avoid running either within the other. If possible, >> try running each standalone. For inter process communication, try using >> socket communication, either with straight sockets or via something like >> zeromq or similar. >> >> --Ford >> On May 20, 2016 10:12 AM, "Nikolaus Neusser" wrote: >> >>> Hi everyone, >>> >>> I'm using flask for the first time and after trying quite a lot, i still >>> fail. :-( >>> I am wondering what i am doing wrong and if flask is the right way to go >>> at all. >>> >>> My objective: >>> - I have a main python application, which basically is based on a >>> PySide (QT4) event loop. >>> This runs a bigger state machine and several other functions. >>> - Now, i want to add a web interface which reads/sets parameters and >>> displays a longer list of >>> strings from the main application (variable length) . >>> >>> Where i am: >>> - The simple flask examples from various tutorials work fine for me. >>> - BUT: I cannot combine my main application with flask, i.e. i don't >>> know how to >>> interchange the data between my main application and the flask >>> route-functions. >>> >>> What i tried: >>> - running flask in a thread (QThread). Works fine for a simple >>> example, i.e. deliver static html >>> and react on get-request >>> - run flask in main thread. Doesn't work since some of my functions >>> rely on the qt event loop >>> - interchanging data between my main application and flask in the >>> thread. I tried this using the >>> qt signal/slot mechanism. >>> This doesn't work, because the signals which i have to define in >>> the main application are not >>> accessible within the flask route-functions. >>> >>> >>> I really hope you can give me some good advice. >>> I can post code snippets if it helps for clarification. >>> >>> Thanks a lot, >>> >>> Nik >>> _______________________________________________ >>> 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 ahall at autodist.com Fri May 27 16:15:36 2016 From: ahall at autodist.com (Alex Hall) Date: Fri, 27 May 2016 16:15:36 -0400 Subject: [Flask] Anything I need to know using Jquery with Flask? Message-ID: I know this is an odd question, and I probably know the answer. But I'm running into some really odd problems with Jquery, problems I can't find anyone else having online. All I can think of is that there's something with Flask, or Jinja, or something in those packages that means I have to do something differently. Mostly, things work fine. But onChange for a select list won't fire correctly, and I'm getting a very obscure error when I try to use a certain selector. Yet, mostly, I have no problems at all. This isn't a Jquery list, so I won't post details here. If there's any way that Flask might cause Jquery to go all funny, though, that would be great to know. Again, I very much doubt this is the case, but I don't know what else to try. Thanks in advance, and thanks for putting up with this off-the-wall question. -- Alex Hall Automatic Distributors, IT department ahall at autodist.com -------------- next part -------------- An HTML attachment was scrubbed... URL: From ford.anthonyj at gmail.com Fri May 27 17:21:44 2016 From: ford.anthonyj at gmail.com (Anthony Ford) Date: Fri, 27 May 2016 16:21:44 -0500 Subject: [Flask] Anything I need to know using Jquery with Flask? In-Reply-To: References: Message-ID: Are you getting an error in your JS console or in the Werkzeug debugger? In general, there is very little you need to use jQuery, since it runs client-side in the browser. jQuery shouldn't even be able to tell you are running Flask vs your bog-standard HTTP server or PHP or whatever. There are a few oddball things you may need to treat differently if you use jQuery to submit AJAX or JSON requests, but that shouldn't affect UI things like onChange events and the like. Anthony Ford, KF5IBN, ford.anthonyj at gmail.com On Fri, May 27, 2016 at 3:15 PM, Alex Hall wrote: > I know this is an odd question, and I probably know the answer. But I'm > running into some really odd problems with Jquery, problems I can't find > anyone else having online. All I can think of is that there's something > with Flask, or Jinja, or something in those packages that means I have to > do something differently. > > Mostly, things work fine. But onChange for a select list won't fire > correctly, and I'm getting a very obscure error when I try to use a certain > selector. Yet, mostly, I have no problems at all. > > This isn't a Jquery list, so I won't post details here. If there's any way > that Flask might cause Jquery to go all funny, though, that would be great > to know. Again, I very much doubt this is the case, but I don't know what > else to try. Thanks in advance, and thanks for putting up with this > off-the-wall question. > > -- > Alex Hall > Automatic Distributors, IT department > ahall at autodist.com > > _______________________________________________ > Flask mailing list > Flask at python.org > https://mail.python.org/mailman/listinfo/flask > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From ahall at autodist.com Fri May 27 17:27:16 2016 From: ahall at autodist.com (Alex Hall) Date: Fri, 27 May 2016 17:27:16 -0400 Subject: [Flask] Anything I need to know using Jquery with Flask? In-Reply-To: References: Message-ID: On Fri, May 27, 2016 at 5:21 PM, Anthony Ford wrote: > Are you getting an error in your JS console or in the Werkzeug debugger? > The web console. That's why I knew this would be a very long shot. The > only thing that comes close is a missing CSRF token in the Nginx log after > a certain Jquery selector runs. It tries to disable certain elements of a > form, and I suspect it disables the hidden ones. But everything else is > browser side. > In general, there is very little you need to use jQuery, since it runs > client-side in the browser. jQuery shouldn't even be able to tell you are > running Flask vs your bog-standard HTTP server or PHP or whatever. > > Exactly, but I wasn't sure where else to ask. The only other thing I can think of is that, because of the way my templates are set up, the script is in the body of the page and not the head. But that shouldn't matter. > There are a few oddball things you may need to treat differently if you > use jQuery to submit AJAX or JSON requests, but that shouldn't affect UI > things like onChange events and the like. > I've actually been using Ajax successfully for weeks--Flask made that very easy to set up, and I was able to write the backend in Python. I love doing that. :) > > > > Anthony Ford, > KF5IBN, > ford.anthonyj at gmail.com > > On Fri, May 27, 2016 at 3:15 PM, Alex Hall wrote: > >> I know this is an odd question, and I probably know the answer. But I'm >> running into some really odd problems with Jquery, problems I can't find >> anyone else having online. All I can think of is that there's something >> with Flask, or Jinja, or something in those packages that means I have to >> do something differently. >> >> Mostly, things work fine. But onChange for a select list won't fire >> correctly, and I'm getting a very obscure error when I try to use a certain >> selector. Yet, mostly, I have no problems at all. >> >> This isn't a Jquery list, so I won't post details here. If there's any >> way that Flask might cause Jquery to go all funny, though, that would be >> great to know. Again, I very much doubt this is the case, but I don't know >> what else to try. Thanks in advance, and thanks for putting up with this >> off-the-wall question. >> >> -- >> Alex Hall >> Automatic Distributors, IT department >> ahall at autodist.com >> >> _______________________________________________ >> Flask mailing list >> Flask at python.org >> https://mail.python.org/mailman/listinfo/flask >> >> > -- Alex Hall Automatic Distributors, IT department ahall at autodist.com -------------- next part -------------- An HTML attachment was scrubbed... URL: From ford.anthonyj at gmail.com Fri May 27 17:33:55 2016 From: ford.anthonyj at gmail.com (Anthony Ford) Date: Fri, 27 May 2016 16:33:55 -0500 Subject: [Flask] Anything I need to know using Jquery with Flask? In-Reply-To: References: Message-ID: On Fri, May 27, 2016 at 4:27 PM, Alex Hall wrote: > Exactly, but I wasn't sure where else to ask. The only other thing I can > think of is that, because of the way my templates are set up, the script is > in the body of the page and not the head. But that shouldn't matter. No, it really shouldn't. I use that approach with a lot of my stuff too. It makes pages load a bit faster (there's an article on it somewhere that I don't really feel like looking up right now). One thing that can be a gotcha with that is to make sure your jQuery itself (jquery.xyz.min.js usually) is sourced before your page JS. Now if the onChange is the only thing not working, then that won't be your problem. Are you familiar with the JS debugger in Chrome? If not, look into it. I find it amazingly useful for writing the JS side of my apps. In case you aren't, see these links: https://www.codeschool.com/courses/discover-devtools https://developer.chrome.com/devtools https://developer.chrome.com/devtools/docs/videos Anthony Ford, KF5IBN, ford.anthonyj at gmail.com -------------- next part -------------- An HTML attachment was scrubbed... URL: From zufaellig at outlook.com Sat May 28 21:40:03 2016 From: zufaellig at outlook.com (Patrick Rieser) Date: Sun, 29 May 2016 01:40:03 +0000 Subject: [Flask] Add, Change and Delete Models during runtime with flask-sqlalchemy and flask-migrate In-Reply-To: References: , Message-ID: Dear Anthony Ford, thank you very much for your answer and sorry for my late reply (have been quite ill). I have to admit, that I never fully read up on blueprints. This seems to be quite a good and viable approach and should work well. The thing is, I am curious now about runtime model alterations and I simply want to know in order to satisfy my curiousity how this can be accomplished - even if it goes unused. That being said, I realized that this should be a question for the SQLAlchemy mailing list. Once more thank you very much and best whishes,Patrick From: ford.anthonyj at gmail.com Date: Mon, 16 May 2016 10:17:55 -0500 Subject: Re: [Flask] Add, Change and Delete Models during runtime with flask-sqlalchemy and flask-migrate To: zufaellig at outlook.com CC: flask at python.org Would it not make more sense to run these as separate blueprints/apps? Dispatch to the appropriate blueprint and DB/model once logged in? That seems like it would work for your application, and would require minimal re-writing/modding of the existing Flask/SQLAlchemy packages.Anthony Ford, KF5IBN,ford.anthonyj at gmail.com On Sun, May 15, 2016 at 3:45 PM, Patrick Rieser wrote: The purpose of this is that it would be possible then to serve multiple customers whose frontend overlaps mostly (the rest would be hidden behind feature locks), but where the table layout differs significantly from, a single application. "I don't think this would be possible, a restart is needed at some point to acknowledge the new models. Even if you do the changes directly in the DB, you'll start getting exceptions when the app tries to do stuff with things that no longer exist in your new models."The way I understand it (please correct me if I am wrong) is that the mapper in SQLAlchemy takes the module declaration and mapps it to a table which is stored at the metadata instance. So the plan would be to use manual mapping when a new table is created at runtime and to use metadata.remove to remove the table object from sqlalchemy.I think that one should in theory even be able to use the Table class from sqlalchemy core to define and register tables in as well as use metadata.remove to remove them on the fly and use alembic to do the changes in the database. But I have absolutely no clue if I would be able to still use flask-sqlalchemy which is no hard requirement, but makes thinks a lot easier.The problem is this goes way beyond my knowledge of flask-sqlalchmy (which as far as I know only wraps and extends sqlalchemy) and sqlalchemy in general, so I was looking for some pointers or help.Best wishes,PatrickDate: Sun, 15 May 2016 10:58:40 +0200Subject: Re: [Flask] Add, Change and Delete Models during runtime with flask-sqlalchemy and flask-migrateFrom: alejoar at gmail.comTo: zufaellig at outlook.comCC: flask at python.orgIf you change the models you are basically changing the app code.I don't think this would be possible, a restart is needed at some point to acknowledge the new models. Even if you do the changes directly in the DB, you'll start getting exceptions when the app tries to do stuff with things that no longer exist in your new models. What's the purpose of this? On May 15, 2016 04:31, "Patrick Rieser" wrote:Hello everybody, so I try to add, change and delete Models during runtime with flask-sqlalchemy and flask-migrate . To do that I plan to write/change/delete the mymodel.py file, create the migration script and then do the migration. So far so good. The problem is that I don't know what internally happens in Flask and flask-sqlalchemy. I guess that there is at least some internal caching/dict to store additional information (like class names, fields etc.) that should be added/changed/cleared accordingly. Does anybody have any clue about this? Any help is greatly appreciated! With kind regards,Patrick_______________________________________________Flask mailing listFlask at python.orghttps://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 aimanparvaiz at gmail.com Sun May 29 21:56:28 2016 From: aimanparvaiz at gmail.com (aiman parvaiz) Date: Sun, 29 May 2016 18:56:28 -0700 Subject: [Flask] Flask secret key for mobile app client Message-ID: Hi all I am new to flask and am writing a REST API backend for a mobile app. My question is how can I ensure that call to my endpoints is only being done by my mobile app and not by some one who has guessed the endpoint. What would be the best way to avoid this kind of behavior. Thanks -------------- next part -------------- An HTML attachment was scrubbed... URL: From unai at sysbible.org Mon May 30 00:09:38 2016 From: unai at sysbible.org (Unai Rodriguez) Date: Mon, 30 May 2016 12:09:38 +0800 Subject: [Flask] Flask secret key for mobile app client In-Reply-To: References: Message-ID: <1464581378.1311398.622307097.45728CEA@webmail.messagingengine.com> If the people using the app can be anyone (I.e. it's open to general public) you cannot. Typically SSL I.e. HTTPS) plus authentication is used for this. If the people that are supposed to access have something in common (I.e. they come from a specific office, etc) then you might be able to add rules on a firewalll. But that can be a problem (rules not correct or people accessing through a VPN etc). I guess the only way is if the app is served only to the people that are supposed to access the through some sort of a corporate /private network . -- unai On Mon, May 30, 2016, at 09:56 AM, aiman parvaiz wrote: > Hi all > I am new to flask and am writing a REST API backend for a mobile app. > My question is how can I ensure that call to my endpoints is only > being done by my mobile app and not by some one who has guessed the > endpoint. > What would be the best way to avoid this kind of behavior. > Thanks > _________________________________________________ > Flask mailing list > Flask at python.org > https://mail.python.org/mailman/listinfo/flask -------------- next part -------------- An HTML attachment was scrubbed... URL: From aimanparvaiz at gmail.com Mon May 30 03:07:04 2016 From: aimanparvaiz at gmail.com (Aiman Parvaiz) Date: Mon, 30 May 2016 00:07:04 -0700 Subject: [Flask] Flask secret key for mobile app client In-Reply-To: <1464581378.1311398.622307097.45728CEA@webmail.messagingengine.com> References: <1464581378.1311398.622307097.45728CEA@webmail.messagingengine.com> Message-ID: <755EEE64-E942-45B7-9108-B1BFB227B27C@gmail.com> Thanks for the response Unai. This app would be open to the general public indeed. Can you please throw more light on SSL+ authentication? I would be using SSL for this but what do you mean by authentication from mobile phone? Sent from my iPhone > On May 29, 2016, at 9:09 PM, Unai Rodriguez wrote: > > If the people using the app can be anyone (I.e. it's open to general public) you cannot. Typically SSL I.e. HTTPS) plus authentication is used for this. > > If the people that are supposed to access have something in common (I.e. they come from a specific office, etc) then you might be able to add rules on a firewalll. But that can be a problem (rules not correct or people accessing through a VPN etc). I guess the only way is if the app is served only to the people that are supposed to access the through some sort of a corporate /private network . > > > > -- unai > > >> On Mon, May 30, 2016, at 09:56 AM, aiman parvaiz wrote: >> Hi all >> I am new to flask and am writing a REST API backend for a mobile app. My question is how can I ensure that call to my endpoints is only being done by my mobile app and not by some one who has guessed the endpoint. >> What would be the best way to avoid this kind of behavior. >> Thanks >> _______________________________________________ >> 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 aimanparvaiz at gmail.com Mon May 30 03:46:03 2016 From: aimanparvaiz at gmail.com (aiman parvaiz) Date: Mon, 30 May 2016 00:46:03 -0700 Subject: [Flask] Flask secret key for mobile app client In-Reply-To: <755EEE64-E942-45B7-9108-B1BFB227B27C@gmail.com> References: <1464581378.1311398.622307097.45728CEA@webmail.messagingengine.com> <755EEE64-E942-45B7-9108-B1BFB227B27C@gmail.com> Message-ID: The case under consideration is that right now any one can jump on a tool as simple as Postman(on Chrome browser), construct the API call and get data from the backend. I need a way to allow only mobile devices with the installed app to see the returned data and how can I ensure that a API call from any client other than mobile devices don't get a response from my server. I would appreciate any help I can get here. Thanks On Mon, May 30, 2016 at 12:07 AM, Aiman Parvaiz wrote: > Thanks for the response Unai. This app would be open to the general public > indeed. Can you please throw more light on SSL+ authentication? > I would be using SSL for this but what do you mean by authentication from > mobile phone? > > > Sent from my iPhone > > On May 29, 2016, at 9:09 PM, Unai Rodriguez wrote: > > If the people using the app can be anyone (I.e. it's open to general > public) you cannot. Typically SSL I.e. HTTPS) plus authentication is used > for this. > > If the people that are supposed to access have something in common (I.e. > they come from a specific office, etc) then you might be able to add rules > on a firewalll. But that can be a problem (rules not correct or people > accessing through a VPN etc). I guess the only way is if the app is served > only to the people that are supposed to access the through some sort of a > corporate /private network . > > > > -- unai > > > On Mon, May 30, 2016, at 09:56 AM, aiman parvaiz wrote: > > Hi all > I am new to flask and am writing a REST API backend for a mobile app. My > question is how can I ensure that call to my endpoints is only being done > by my mobile app and not by some one who has guessed the endpoint. > What would be the best way to avoid this kind of behavior. > Thanks > *_______________________________________________* > 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 saikat_sarkar at hotmail.com Mon May 30 07:41:35 2016 From: saikat_sarkar at hotmail.com (saikat_sarkar) Date: Mon, 30 May 2016 17:11:35 +0530 Subject: [Flask] Flask secret key for mobile app client Message-ID: Stop this spam Saikat Sent from Samsung Mobile -------- Original message -------- From: aiman parvaiz Date:30/05/2016 1:16 PM (GMT+05:30) To: Unai Rodriguez Cc: flask at python.org Subject: Re: [Flask] Flask secret key for mobile app client The case under consideration is that right now any one can jump on a tool as simple as Postman(on Chrome browser), construct the API call and get data from the backend. I need a way to allow only mobile devices with the installed app to see the returned data and how can I ensure that a API call from any client other than mobile devices don't get a response from my server. I would appreciate any help I can get here. Thanks On Mon, May 30, 2016 at 12:07 AM, Aiman Parvaiz wrote: > Thanks for the response Unai. This app would be open to the general public > indeed. Can you please throw more light on SSL+ authentication? > I would be using SSL for this but what do you mean by authentication from > mobile phone? > > > Sent from my iPhone > > On May 29, 2016, at 9:09 PM, Unai Rodriguez wrote: > > If the people using the app can be anyone (I.e. it's open to general > public) you cannot. Typically SSL I.e. HTTPS) plus authentication is used > for this. > > If the people that are supposed to access have something in common (I.e. > they come from a specific office, etc) then you might be able to add rules > on a firewalll. But that can be a problem (rules not correct or people > accessing through a VPN etc). I guess the only way is if the app is served > only to the people that are supposed to access the through some sort of a > corporate /private network . > > > > -- unai > > > On Mon, May 30, 2016, at 09:56 AM, aiman parvaiz wrote: > > Hi all > I am new to flask and am writing a REST API backend for a mobile app. My > question is how can I ensure that call to my endpoints is only being done > by my mobile app and not by some one who has guessed the endpoint. > What would be the best way to avoid this kind of behavior. > Thanks > *_______________________________________________* > 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: -------------- next part -------------- _______________________________________________ Flask mailing list Flask at python.org https://mail.python.org/mailman/listinfo/flask From coreybrett at gmail.com Mon May 30 09:37:21 2016 From: coreybrett at gmail.com (Corey Boyle) Date: Mon, 30 May 2016 09:37:21 -0400 Subject: [Flask] Flask secret key for mobile app client In-Reply-To: References: Message-ID: You can make it non-trivial for someone to access the back end directly, but I don't think you can ever make it impossible. Any type of secret that you embed in the application, could always be extracted. On May 30, 2016 7:43 AM, "saikat_sarkar" wrote: > Stop this spam > > > Saikat > Sent from Samsung Mobile > > > -------- Original message -------- > From: aiman parvaiz > Date:30/05/2016 1:16 PM (GMT+05:30) > To: Unai Rodriguez > Cc: flask at python.org > Subject: Re: [Flask] Flask secret key for mobile app client > > The case under consideration is that right now any one can jump on a tool > as simple as Postman(on Chrome browser), construct the API call and get > data from the backend. I need a way to allow only mobile devices with the > installed app to see the returned data and how can I ensure that a API call > from any client other than mobile devices don't get a response from my > server. > > I would appreciate any help I can get here. > > Thanks > > On Mon, May 30, 2016 at 12:07 AM, Aiman Parvaiz > wrote: > > Thanks for the response Unai. This app would be open to the general public > indeed. Can you please throw more light on SSL+ authentication? > I would be using SSL for this but what do you mean by authentication from > mobile phone? > > > Sent from my iPhone > > On May 29, 2016, at 9:09 PM, Unai Rodriguez wrote: > > If the people using the app can be anyone (I.e. it's open to general > public) you cannot. Typically SSL I.e. HTTPS) plus authentication is used > for this. > > If the people that are supposed to access have something in common (I.e. > they come from a specific office, etc) then you might be able to add rules > on a firewalll. But that can be a problem (rules not correct or people > accessing through a VPN etc). I guess the only way is if the app is served > only to the people that are supposed to access the through some sort of a > corporate /private network . > > > > -- unai > > > On Mon, May 30, 2016, at 09:56 AM, aiman parvaiz wrote: > > Hi all > I am new to flask and am writing a REST API backend for a mobile app. My > question is how can I ensure that call to my endpoints is only being done > by my mobile app and not by some one who has guessed the endpoint. > What would be the best way to avoid this kind of behavior. > Thanks > *_______________________________________________* > 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 markus at unterwaditzer.net Mon May 30 09:58:09 2016 From: markus at unterwaditzer.net (Markus Unterwaditzer) Date: Mon, 30 May 2016 15:58:09 +0200 Subject: [Flask] Flask secret key for mobile app client In-Reply-To: References: Message-ID: Then unsubscribe from this mailing list. On 30 May 2016 13:41:35 CEST, saikat_sarkar wrote: >Stop this spam > > >Saikat >Sent from Samsung Mobile > >-------- Original message -------- >From: aiman parvaiz >Date:30/05/2016 1:16 PM (GMT+05:30) >To: Unai Rodriguez >Cc: flask at python.org >Subject: Re: [Flask] Flask secret key for mobile app client > >The case under consideration is that right now any one can jump on a >tool >as simple as Postman(on Chrome browser), construct the API call and get >data from the backend. I need a way to allow only mobile devices with >the >installed app to see the returned data and how can I ensure that a API >call >from any client other than mobile devices don't get a response from my >server. > >I would appreciate any help I can get here. > >Thanks > >On Mon, May 30, 2016 at 12:07 AM, Aiman Parvaiz > >wrote: > >> Thanks for the response Unai. This app would be open to the general >public >> indeed. Can you please throw more light on SSL+ authentication? >> I would be using SSL for this but what do you mean by authentication >from >> mobile phone? >> >> >> Sent from my iPhone >> >> On May 29, 2016, at 9:09 PM, Unai Rodriguez >wrote: >> >> If the people using the app can be anyone (I.e. it's open to general >> public) you cannot. Typically SSL I.e. HTTPS) plus authentication is >used >> for this. >> >> If the people that are supposed to access have something in common >(I.e. >> they come from a specific office, etc) then you might be able to add >rules >> on a firewalll. But that can be a problem (rules not correct or >people >> accessing through a VPN etc). I guess the only way is if the app is >served >> only to the people that are supposed to access the through some sort >of a >> corporate /private network . >> >> >> >> -- unai >> >> >> On Mon, May 30, 2016, at 09:56 AM, aiman parvaiz wrote: >> >> Hi all >> I am new to flask and am writing a REST API backend for a mobile app. >My >> question is how can I ensure that call to my endpoints is only being >done >> by my mobile app and not by some one who has guessed the endpoint. >> What would be the best way to avoid this kind of behavior. >> Thanks >> *_______________________________________________* >> 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 -- Sent from my Android device with K-9 Mail. Please excuse my brevity. -------------- next part -------------- An HTML attachment was scrubbed... URL: From aco at miza.org Mon May 30 14:59:01 2016 From: aco at miza.org (Aco Strkalj) Date: Mon, 30 May 2016 13:59:01 -0500 Subject: [Flask] Developers Message-ID: <2F6A7CFC-0956-4544-B077-9E15CFDD7893@miza.org> I?m looking for a highly skilled python developer with a master understanding of flask to build a web app related integrating python with transmission and ffmpeg and a bunch of data match making. Work from home at your time, great pay. If interested, email me. Thanks! From luca at lesinigo.it Tue May 31 04:16:23 2016 From: luca at lesinigo.it (Luca Lesinigo) Date: Tue, 31 May 2016 10:16:23 +0200 Subject: [Flask] Flask secret key for mobile app client In-Reply-To: References: <1464581378.1311398.622307097.45728CEA@webmail.messagingengine.com> <755EEE64-E942-45B7-9108-B1BFB227B27C@gmail.com> Message-ID: <07FB7617-6140-47D7-A6EC-6EB86F9EEFE9@lesinigo.it> Il giorno 30 mag 2016, alle ore 09:46, aiman parvaiz ha scritto: > The case under consideration is that right now any one can jump on a tool as simple as Postman(on Chrome browser), construct the API call and get data from the backend. I need a way to allow only mobile devices with the installed app to see the returned data and how can I ensure that a API call from any client other than mobile devices don't get a response from my server. > I would appreciate any help I can get here. First of all you have to put your API on an HTTPS endpoint. You can then put a first layer of security by embedding the server public certificate in the mobile app (client). This will gain you nothing for what you are asking (it is really easy for anyone to extract whatever they want from any public app) but your app can use certificate pinning to be sure it?s talking to the real server and not to someone else. The trust to this certificate is enforced by the mobile operating system (i.e. iOS or Android) that under normal circumstances will refuse to run application not coming from the official app store and/or applications that have been tampered with. Of course you can do nothing for people with rooted or otherwise modified mobile operating system, thay can always get a modified version of your app with a different certificate if they want or if someone maliciously do that. Then you have to implement some sort of authentication for the users of your app: for example have the user fill a form including their email address and send a verification email to that address, or stuff like that. Bottom line is: - your server has no way to be sure if it?s talking to your genuine client app or to a modified version of it or to something entirely different. You must think of it just like any public-facing service (api, website, whatever) that doesn?t know who?s knocking at the door - your client app can only be sure it?s talking to your genuine server if it is running on a genuine, unmodified and uncompromised mobile operating system that got the app from a trusted source like the official app store -- Luca Lesinigo From aimanparvaiz at gmail.com Tue May 31 18:30:16 2016 From: aimanparvaiz at gmail.com (aiman parvaiz) Date: Tue, 31 May 2016 15:30:16 -0700 Subject: [Flask] Flask secret key for mobile app client In-Reply-To: <07FB7617-6140-47D7-A6EC-6EB86F9EEFE9@lesinigo.it> References: <1464581378.1311398.622307097.45728CEA@webmail.messagingengine.com> <755EEE64-E942-45B7-9108-B1BFB227B27C@gmail.com> <07FB7617-6140-47D7-A6EC-6EB86F9EEFE9@lesinigo.it> Message-ID: Thanks a lot Luca and others for all the advice. I would be using HTTPS for sure, for authentication I want to use something like Flask Login so that I can check if its a logged in user making a request or not. Does Flask Login work with Android app's? I read the documentation and understand that does user session management but being new in this domain am not sure if a mobile app is a legit client for Flask login. On Tue, May 31, 2016 at 1:16 AM, Luca Lesinigo wrote: > Il giorno 30 mag 2016, alle ore 09:46, aiman parvaiz < > aimanparvaiz at gmail.com> ha scritto: > > The case under consideration is that right now any one can jump on a > tool as simple as Postman(on Chrome browser), construct the API call and > get data from the backend. I need a way to allow only mobile devices with > the installed app to see the returned data and how can I ensure that a API > call from any client other than mobile devices don't get a response from my > server. > > I would appreciate any help I can get here. > First of all you have to put your API on an HTTPS endpoint. > > You can then put a first layer of security by embedding the server public > certificate in the mobile app (client). > This will gain you nothing for what you are asking (it is really easy for > anyone to extract whatever they want from any public app) but your app can > use certificate pinning to be sure it?s talking to the real server and not > to someone else. > The trust to this certificate is enforced by the mobile operating system > (i.e. iOS or Android) that under normal circumstances will refuse to run > application not coming from the official app store and/or applications that > have been tampered with. > Of course you can do nothing for people with rooted or otherwise modified > mobile operating system, thay can always get a modified version of your app > with a different certificate if they want or if someone maliciously do that. > > Then you have to implement some sort of authentication for the users of > your app: for example have the user fill a form including their email > address and send a verification email to that address, or stuff like that. > > Bottom line is: > - your server has no way to be sure if it?s talking to your genuine client > app or to a modified version of it or to something entirely different. You > must think of it just like any public-facing service (api, website, > whatever) that doesn?t know who?s knocking at the door > - your client app can only be sure it?s talking to your genuine server if > it is running on a genuine, unmodified and uncompromised mobile operating > system that got the app from a trusted source like the official app store > > -- > Luca Lesinigo > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From nik.neusser at gmx.de Fri May 20 11:05:22 2016 From: nik.neusser at gmx.de (Nikolaus Neusser) Date: Fri, 20 May 2016 15:05:22 -0000 Subject: [Flask] Interchange data with main python application Message-ID: <7fc87ce0-48ff-79e7-dd8b-6078b614c375@gmx.de> Hi everyone, I'm using flask for the first time and after trying quite a lot, i still fail. :-( I am wondering what i am doing wrong and if flask is the right way to go at all. My objective: - I have a main python application, which basically is based on a PySide (QT4) event loop. This runs a bigger state machine and several other functions. - Now, i want to add a web interface which reads/sets parameters and displays a longer list of strings from the main application (variable length) . Where i am: - The simple flask examples from various tutorials work fine for me. - BUT: I cannot combine my main application with flask, i.e. i don't know how to interchange the data between my main application and the flask route-functions. What i tried: - running flask in a thread (QThread). Works fine for a simple example, i.e. deliver static html and react on get-request - run flask in main thread. Doesn't work since some of my functions rely on the qt event loop - interchanging data between my main application and flask in the thread. I tried this using the qt signal/slot mechanism. This doesn't work, because the signals which i have to define in the main application are not accessible within the flask route-functions. I really hope you can give me some good advice. I can post code snippets if it helps for clarification. Thanks a lot, From wangjia at kiyes.cn Mon May 23 04:28:49 2016 From: wangjia at kiyes.cn (wangjia at kiyes.cn) Date: Mon, 23 May 2016 08:28:49 -0000 Subject: [Flask] about flask session expire problem Message-ID: <201605231628255039599@kiyes.cn> hi: I use nginx+uwsgi+flask(0.10.1) build environment , now i want to realize platform return to home page when user session expire , but i dont know how to setting , can you guide me? thanks Best Regards, Venture -------------- next part -------------- An HTML attachment was scrubbed... URL: