6 ms·
Getting a Flask website up and running in Ubuntu
- espeed 15y agoIf you don't want to mess with setting up Web servers, sign up for a Heroku account (https://api.heroku.com/signup https://api.heroku.com/signup), and host it on a free dyno. First set up the Heroku "toolbelt" (https://toolbelt.heroku.com https://toolbelt.heroku.com), and once that's done, you can run this bash script (https://gist.github.com/2622850 https://gist.github.com/2622850) to create and deploy a "hello world" Flask app on Heroku: $ heroku login $ bash setup.sh helloworld $ cd helloworld $ git push heroku master It should return a live Web URL for your app: http://strong-stream-5848.herokuapp.com deployed to Heroku Kenneth (http://kennethreitz.com http://kennethreitz.com) has shown you can get good performance with Flask on the free dyno (http://flask.pocoo.org/mailinglist/archive/2012/2/22/flask-on-heroku-%2B-gunicorn-static-files/#cff05916ae6854557b93d0226cb87151 http://flask.pocoo.org/mailinglist/archive/2012/2/22/flask-o...). See the Heroku Quickstart (https://devcenter.heroku.com/articles/quickstart https://devcenter.heroku.com/articles/quickstart) and Python tutorial (https://devcenter.heroku.com/articles/python https://devcenter.heroku.com/articles/python) for details.
- tocomment 15y agoDoes Django get good performancee on the free dyno?
- peter_l_downs 15y agoI found this article interesting/useful because it is focused on DIY. I've been using dotcloud for hosting my flask apps, and it's very easy, but if I ever want to do it myself one day I now know how.
- president 15y agoOr Google App Engine, which is even easier. All you do is load your application into their GUI and click 'deploy'. There are templates abound: https://github.com/gumho/minimal-flask-gae-template https://github.com/gumho/minimal-flask-gae-template https://github.com/kamalgill/flask-appengine-template https://github.com/kamalgill/flask-appengine-template https://github.com/toomore-such/template-gae-with-flask https://github.com/toomore-such/template-gae-with-flask
- shykes 15y agoHere's how to do the same thing on dotCloud: Step 1: sign up for a dotCloud account: (http://dotcloud.com http://dotcloud.com) Step 2: Follow these steps: http://flask.pocoo.org/snippets/48/ http://flask.pocoo.org/snippets/48/
- kfk 15y agoYesterday I spent 2 hrs to figure out why dotcloud keeps telling me that it finds no uwsgi. I managed to load another flask website with the same structure. I am now thinking numpy and pandas may be too heavy? Anyway, a detailed log of pushes would really help a lot.
- shykes 15y agoHi there, you can definitely install numpy and panda into a dotcloud app. Simply add them to a file called requirements.txt, they should be installed automatically. You can run 'dotcloud logs' to access detailed logs of your app's deployment and activity, that might help. Otherwise drop us a line at support@dotcloud.com and we'll be happy to help you out!
- kfk 15y agoThanks!
- diminish 15y agois the use of /srv as the installation location a good choice? I usually install all my apps under /var/www or /var/apps.
- benmanns 15y agowget http://nginx.org/keys/nginx_signing.key I don't understand why someone would go to the trouble of signing their packages, and then serve the key exclusively over HTTP.
- TazeTSchnitzel 15y ago"Me too!" security, where you add "security" not because you understand it and its benefits, but because other people do it.
- salimmadjd 15y agoGreat post...may I suggest expanding on this and install a database as well and a templating engine
- espeed 15y agoThe Jinja2 templating engine (http://jinja.pocoo.org/docs/ http://jinja.pocoo.org/docs/) is installed by default with Flask.
- salimmadjd 15y agoI understand...but I rather stay within python syntax as much as possible and use something like Mako. I know you might send me to pylon, but flask's simplicity and flexibilty make it more alluring to me.
- gouranga 15y agoCall me lazy but I found it much easier to host on apache and mod_wsgi. Ubuntu/debian derivatives have a nice easy to manage virtual hosting system. Quite impressed with flask though - lovely simple framework that works the same way my brain does.
- zokier 15y agoWhy not use nginx/uwsgi/virtualenv from ubuntu repositories? In case of uwsgi, you'd get ready-made upstart and logrotate scripts, and with virtualenv you get automatic updating with the rest of packages.
- conradev 15y agoI prefer using the latest stable versions and not having to depend on the Ubuntu packages to be updated.
- srconstantin 15y agoHow much of this will work on a Mac?
- conradev 15y agoIf you read the 'Portability' portion on the bottom, you can run a test server with just uWSGI. For actually deploying with Mac, that would be entirely different.