← Flask tutorial

Flask

Introduction to Flask

Flask is a "micro" Python web framework, unlike Django, it doesn't ship an ORM or admin site by default. It gives you routing and request handling, and you add whatever else you need (a database layer, forms) as separate packages, chosen deliberately rather than bundled in.

Example: the smallest complete Flask app

from flask import Flask

app = Flask(__name__)

@app.route("/")
def home():
    return "Hello, world!"

if __name__ == "__main__":
    app.run(debug=True)
Hello, world!

That's a genuinely complete, runnable web application in nine lines, Flask's minimalism is exactly why it's a popular choice for small APIs and services where you want fine control over what's included, rather than Django's more complete, more opinionated "batteries included" approach.

Example
from flask import Flask

app = Flask(__name__)

@app.route("/")
def home():
    return "Hello, world!"

if __name__ == "__main__":
    app.run(debug=True)
Output
Hello, world!
Ready to go further?

These free tutorials are a preview, our Backend Development cohort covers it in depth, with a real project and a cohort alongside you. Active

Enroll in Backend Development
Don't miss out

Ready to build something real?

Create a free account to enroll in a track, and get notified the moment a cohort opens.

Create free account