Hacker News new | comments | show | ask | jobs | submit login
Getting a Flask website up and running in Ubuntu (kramerapps.com)
64 points by conradev on May 7, 2012 | hide | past | web | favorite | 22 comments



If you don't want to mess with setting up Web servers, sign up for a Heroku account (https://api.heroku.com/signup), and host it on a free dyno.

First set up the Heroku "toolbelt" (https://toolbelt.heroku.com), and once that's done, you can run this bash script (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) has shown you can get good performance with Flask on the free dyno (http://flask.pocoo.org/mailinglist/archive/2012/2/22/flask-o...).

See the Heroku Quickstart (https://devcenter.heroku.com/articles/quickstart) and Python tutorial (https://devcenter.heroku.com/articles/python) for details.


Or 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/kamalgill/flask-appengine-template

https://github.com/toomore-such/template-gae-with-flask


I 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.


Does Django get good performancee on the free dyno?


  wget 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.


"Me too!" security, where you add "security" not because you understand it and its benefits, but because other people do it.


Here's how to do the same thing on dotCloud:

Step 1: sign up for a dotCloud account: (http://dotcloud.com)

Step 2: Follow these steps: http://flask.pocoo.org/snippets/48/


Yesterday 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.


Hi 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!


Thanks!


Call 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.


Why 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.


I prefer using the latest stable versions and not having to depend on the Ubuntu packages to be updated.


is the use of /srv as the installation location a good choice? I usually install all my apps under /var/www or /var/apps.


It's really a matter of preference.


It shouldn't make any difference, except that /var may be on a filesystem on its own (but this is becoming quite uncommon nowadays).


So might /srv.


Great post...may I suggest expanding on this and install a database as well and a templating engine


The Jinja2 templating engine (http://jinja.pocoo.org/docs/) is installed by default with Flask.


I 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.


How much of this will work on a Mac?


If 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.




Guidelines | FAQ | Support | API | Security | Lists | Bookmarklet | Legal | Apply to YC | Contact

Search: