Skip to content
This repository was archived by the owner on Apr 11, 2018. It is now read-only.

Flask: Hello World

evgenymartynov edited this page Feb 10, 2013 · 1 revision

If you are on Windows, you're going to have a bad time following this guide. I'm testing this on Ubuntu 10.04, but it should work on any recent distro. It's probably better to run something lightweight in a Virtualbox, if you're not willing to commit to a Linux install.

Excuse the wall of text, it looked prettier on the mailing list.


Fire up a terminal. We are going to create a "virtualenv" for development -- this keeps all required packages in that directory, and these instructions would work across most environments. To do this, first install python-virtualenv or whatever your distro calls it (sudo apt-get install python-virtualenv). To create a virtualenv, run virtualenv --no-site-packages csesoc-bark. It will download a few things and you'll see a new directory, csesoc-bark. Change to it.

From inside there, you need to activate it with . bin/activate. Note the dot at the beginning, followed by a space. That tells the shell to read instructions from that file, rather than executing it separately. If that made no sense, ignore me. Your prompt will change to (csesoc-bark) OLDPROMT or something. That means it's working. If it does not say that, the virtualenv isn't active. It's a per-terminal thing.

To download Flask, we can now use pip (a python package manager). Run pip install flask once you've activated the virtualenv.

Create another dir (preferably inside csesoc-bark, but it doesn't matter), call it hello-world. Change to it, create a new file hello.py, and copy the "minimal application" from http://flask.pocoo.org/docs/quickstart/ to it.

If you now run python hello.py, you should see this happen: http://archimedes.epochfail.com/f/2013-02/Screenshot-None.png

If you now click on that link, it takes you to the "Hello world" page.

You have just set up a Hello world in Flask.

Clone this wiki locally