

Getting a Flask website up and running in Ubuntu - conradev
http://kramerapps.com/blog/post/22551999777/flask-uwsgi-nginx-ubuntu

======
espeed
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...](http://flask.pocoo.org/mailinglist/archive/2012/2/22/flask-
on-heroku-%2B-gunicorn-static-files/#cff05916ae6854557b93d0226cb87151)).

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

~~~
president
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>

------
benmanns

      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.

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

------
shykes
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/>

~~~
kfk
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.

~~~
shykes
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!

~~~
kfk
Thanks!

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

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

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

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

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

~~~
DHowett
So might /srv.

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

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

~~~
salimmadjd
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.

------
srconstantin
How much of this will work on a Mac?

~~~
conradev
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.

