From emlyn.je.price at gmail.com Fri Jan 4 13:40:19 2019 From: emlyn.je.price at gmail.com (Emlyn Price) Date: Fri, 4 Jan 2019 18:40:19 +0000 Subject: [Flask] Deploying with mod_wsgi with factory function in __init__.py Message-ID: Hi, I have been writing my first program using flask and ran into some confusion when writing the my_application.wsgi file. I followed the tutorial application structure, using a create_app() function in a file called __init__.py. I installed the project in a virtualenv. The flask docs say that for most apps the following file should be sufficient: `from yourapplication import app as application`. When I tried to use a file like this I get `TypeError: 'module' object not callable` in the apache logs. After some searching I found that the correct way to import an app like that is: ``` from app import create_app application = create_app() ``` This is the first time I have written a python project which can be installed in this way. I would like to know if this is the expected way to have to import a project written with a factory function in __init__.py? If so, I think it would be useful to have a comment stating so in the docs. I am happy to create a pull request if so. I am using: python 3.5.3 flask 1.0.2 mod_wsgi 4.5.11-1, installed from raspbian stretch repositories Raspbian Stretch Thanks, Emlyn -------------- next part -------------- An HTML attachment was scrubbed... URL: From nicolas at lemanchet.fr Fri Jan 4 16:18:30 2019 From: nicolas at lemanchet.fr (Nicolas Le Manchet) Date: Fri, 04 Jan 2019 22:18:30 +0100 Subject: [Flask] Deploying with mod_wsgi with factory function in __init__.py In-Reply-To: References: Message-ID: <1546636710.3618229.1625795928.01858DB2@webmail.messagingengine.com> Hi, Short answer: yes, the behavior you see is expected. All WSGI servers need an application (a callable that follows specific conventions) to work. - Using Flask without application factory it's enough to just import the global application that already exists. - Using Flask with application factory no global application exists so it is required to create an application using the factory so the WSGI server can access it. On Fri, Jan 4, 2019, at 19:40, Emlyn Price wrote: > Hi, > > I have been writing my first program using flask and ran into some > confusion when writing the my_application.wsgi file. I followed the > tutorial application structure, using a create_app() function in a file > called __init__.py. I installed the project in a virtualenv. > > The flask docs say that for most apps the following file should be > sufficient: `from yourapplication import app as application`. When I tried > to use a file like this I get `TypeError: 'module' object not callable` in > the apache logs. > > After some searching I found that the correct way to import an app like > that is: > > ``` > from app import create_app > application = create_app() > ``` > > This is the first time I have written a python project which can be > installed in this way. I would like to know if this is the expected way to > have to import a project written with a factory function in __init__.py? > > If so, I think it would be useful to have a comment stating so in the docs. > I am happy to create a pull request if so. > > I am using: > python 3.5.3 > flask 1.0.2 > mod_wsgi 4.5.11-1, installed from raspbian stretch repositories > Raspbian Stretch > > > Thanks, > Emlyn > _______________________________________________ > Flask mailing list > Flask at python.org > https://mail.python.org/mailman/listinfo/flask -- Nicolas Le Manchet From lijin.abc at gmail.com Fri Jan 25 16:00:07 2019 From: lijin.abc at gmail.com (Jin Li) Date: Fri, 25 Jan 2019 15:00:07 -0600 Subject: [Flask] How to free hosting a Flask app with custom domain? In-Reply-To: References: Message-ID: Dear all, I want to deploy a Flask application in a free host (with MySQL for data storage), and I want to use my custom domain to access the host. I have tried Hosted Options at http://flask.pocoo.org/docs/1.0/deploying/. However, they are either non-free for Cloud database or non-free for custom domain redirection. Can anyone have a recommendation for my free hosting of Flask application with my custom domain? Thank you. Best regards, Jin From gabor at szabgab.com Sat Jan 26 02:57:56 2019 From: gabor at szabgab.com (Gabor Szabo) Date: Sat, 26 Jan 2019 09:57:56 +0200 Subject: [Flask] How to free hosting a Flask app with custom domain? In-Reply-To: References: Message-ID: Hi Jin, I don't know about absolutely free options, but you could use the free tier or free period of Google GCP, Amazon AWS, or Microsoft Azure and have your own small VPS for a year or maybe longer. Then you switch to the other provider or by that time you make enough money from your site to pay for its hosting. I personally have been using Digital Ocean ($5/month for the smallest instance) for several years now, but AFAIK I've never paid. I have a referral button on my site and apparently enough people are using it so my hosting fee at DO is covered by the referral fees. BTW I just searched for "Digital Ocean free" and saw a number of coupons that offer you various amount of free credit for DO. So you can try that option as well and hope that you generate enough referrals to cover your costs. regards Gabor On Fri, Jan 25, 2019 at 11:00 PM Jin Li wrote: > Dear all, > > I want to deploy a Flask application in a free host (with MySQL for > data storage), and I want to use my custom domain to access the host. > > I have tried Hosted Options at > http://flask.pocoo.org/docs/1.0/deploying/. However, they are either > non-free for Cloud database or non-free for custom domain redirection. > > Can anyone have a recommendation for my free hosting of Flask > application with my custom domain? Thank you. > > Best regards, > Jin > _______________________________________________ > Flask mailing list > Flask at python.org > https://mail.python.org/mailman/listinfo/flask > -------------- next part -------------- An HTML attachment was scrubbed... URL: From badrihippo at gmail.com Sat Jan 26 07:36:43 2019 From: badrihippo at gmail.com (badrihippo at gmail.com) Date: Sat, 26 Jan 2019 17:36:43 +0500 Subject: [Flask] How to free hosting a Flask app with custom domain? In-Reply-To: References: Message-ID: <1548506203.4989.2@smtp.gmail.com> Hi Jin, You could take a look at HelioHost (heliohost.org). They are committed to offering free, full-featured web hosting. The server is a bit slow and has a 500MB storage limit, but otherwise works pretty well?and supports custom domain redirection too. Note that Flask is not supported out-of-the-box: they use Django instead. A workaround I use is to manually copy the installed Python libraries (the 'lib/pythonX.X/site-packages' directory in any virtualenv installation) to the HelioHost server, then set my script to look in those files for the libraries. This works for pure-python packages (including Flask and its dependencies); however it may not work if a package contains compiled code (such as C), because in that case they'll need to be compiled for the HelioHost machine instead of yours. It took me some trial-and-error to get everything working properly, and debugging is a bit roundabout so you'll have to decide if it's worth the effort (and be prepared for downtime while debugging errors). Let me know if you want more detailed setup instructions. Regards, Badri On Sat, 26 Jan, 2019 at 2:30 AM, Jin Li wrote: > Dear all, > > I want to deploy a Flask application in a free host (with MySQL for > data storage), and I want to use my custom domain to access the host. > > I have tried Hosted Options at > http://flask.pocoo.org/docs/1.0/deploying/. However, they are either > non-free for Cloud database or non-free for custom domain redirection. > > Can anyone have a recommendation for my free hosting of Flask > application with my custom domain? Thank you. > > Best regards, > Jin > _______________________________________________ > 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 Sat Jan 26 21:54:42 2019 From: coreybrett at gmail.com (Corey Boyle) Date: Sat, 26 Jan 2019 21:54:42 -0500 Subject: [Flask] How to free hosting a Flask app with custom domain? In-Reply-To: <1548506203.4989.2@smtp.gmail.com> References: <1548506203.4989.2@smtp.gmail.com> Message-ID: if you have a good connection you could always host on your own box using something like duckdns.org combined with a CNAME record in your own domain i do this for a production site that gets a decent amount of traffic i?m using apache with mod-wsgi on my webserver and haproxy on my gateway all of my images are served via CDN, so only the HTML/CSS/JS are being served over my DOCSIS connection it?s a lot of setup, but works great On Sat, Jan 26, 2019 at 8:49 AM wrote: > Hi Jin, > > You could take a look at HelioHost (heliohost.org). They are committed to > offering free, full-featured web hosting. The server is a bit slow and has > a 500MB storage limit, but otherwise works pretty well?and supports custom > domain redirection too. > > Note that Flask is not supported out-of-the-box: they use Django instead. > A workaround I use is to manually copy the installed Python libraries (the > 'lib/pythonX.X/site-packages' directory in any virtualenv installation) to > the HelioHost server, then set my script to look in those files for the > libraries. > > This works for pure-python packages (including Flask and its > dependencies); however it may not work if a package contains compiled code > (such as C), because in that case they'll need to be compiled for the > HelioHost machine instead of yours. > > It took me some trial-and-error to get everything working properly, and > debugging is a bit roundabout so you'll have to decide if it's worth the > effort (and be prepared for downtime while debugging errors). > > Let me know if you want more detailed setup instructions. > > Regards, > Badri > > On Sat, 26 Jan, 2019 at 2:30 AM, Jin Li wrote: > > Dear all, I want to deploy a Flask application in a free host (with MySQL > for data storage), and I want to use my custom domain to access the host. I > have tried Hosted Options at http://flask.pocoo.org/docs/1.0/deploying/. > However, they are either non-free for Cloud database or non-free for custom > domain redirection. Can anyone have a recommendation for my free hosting of > Flask application with my custom domain? Thank you. Best regards, Jin > _______________________________________________ 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: