Python web development with Flask

flask

Flask is a microframework for Python for web development. It’s BSD licensed and is really easy to use for a personnal web project or even for scalable apps for Heroku.
It requires at least Python 3.3, so if you’re running Debian 7 “wheezy” at the time of writing then you might run into problems.

To setup Flask run this command as root:

# pip install Flask

If you’re missing pip and you are on Windows you should get the lastest version that includes pip.
Then to test if everything went well, you will need to run a script such as this one:

from flask import Flask
app = Flask(__name__)

@app.route("/")
def hello():
    return ("Hello World!")

if (__name__ == "__main__"):
    app.run()

Run it as a simple Python script and you should be greeted with a message saying that it’s running:

* Running on http://localhost:5000/

Now you can start your first webapp by reading the documentation.
If you’re serving web pages with Apache 2, you might want to read this.