Fork me on GitHub

Flask

Flask is a Python web framework built with a small core and easy-to-extend philosophy.

Official Flask logo. Flask Artwork License.

Why is Flask a good web framework choice?

Flask is considered more Pythonic than Django because Flask web application code is in most cases more explicit. Flask is easy to get started with as a beginner because there is little boilerplate code for getting a simple app up and running.

For example, here's a valid "hello world" web application with Flask (the equivalent in Django would be significantly more code):

from flask import Flask
app = Flask(__name__)

@app.route('/')
def hello_world():
    return 'Hello World!'

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

Flask was also written several years after Django and therefore learned from the Python community's reactions as the framework evolved. Jökull Sólberg wrote a great piece articulating to this effect in his experience switching between Flask and Django.

Flask is an implementation of the web frameworks concept. Learn how these pieces fit together in the web development chapter or view the table of contents for all topics.

Flask resources

Open source Flask example projects

Flask project templates

Flask framework learning checklist

  1. Install Flask on your local development machine.

  2. Work through the 18-part Flask tutorial listed first under "Flask resources" above.

  3. Read through Flask Extensions Registry to find out what extensions you'll need to build your project.

  4. Start coding your Flask app based on what you learned from the 18 part Flask tutorial plus open source example applications found below.

  5. Move on to the deployment section to get your initial Flask project on the web.

What web development topic do you want to learn next?

I've built a Python web app, now how do I deploy it?

What other Python web frameworks exist?

How can I version and store my source code?

Sign up here to receive a monthly email with major updates to this site, tutorials and discount codes for Python books.