Flask Explained: The Small Framework That Does Just Enough

Introduction

Django (covered earlier) gives you everything: an ORM, an admin panel, authentication, and a project structure, decided for you. Flask, created by Armin Ronacher in 2010, gives you almost nothing — routing, request handling, and a template engine — and lets you add the rest yourself. That minimalism is the point: for small apps, APIs, and learning, a framework that stays out of the way teaches you more than one that does everything.

A complete app in a few lines

Flask's famous "hello world" is a whole working web app:

from flask import Flask

app = Flask(__name__)

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

@app.route("/users/<name>")
def greet(name):
    return f"Hello, {name}!"

The @app.route decorator maps a URL to a function, <name> captures part of the URL as a variable, and returning a string sends it as the response. Add a database with an extension like Flask-SQLAlchemy, add login with Flask-Login, add forms with Flask-WTF — each piece is a choice, not a default, which is why Flask apps look different from each other in a way Django apps rarely do.

The honest trade

Flask's freedom is also its cost: every project must choose its own database layer, auth, structure, and tooling, so two Flask apps can be organised completely differently, and large teams can drift into inconsistency without discipline. Django's "batteries included" approach avoids that by deciding for you. The rule of thumb: Flask for small services, prototypes, APIs, and learning how the web actually works; Django when you want a full, opinionated structure for a large app from day one.

Takeaway

Flask is Python's microframework: routing and requests, with everything else added by choice. Its smallness is a feature for learning and small apps, and a cost for large teams that need consistency. If Django felt like too much framework, Flask is the other end of the scale — and a fine place to understand what a web framework actually does.

Comments

Popular posts from this blog

Swift Explained: Apple's Language for iPhone, Mac, and More

Flutter Explained: One Codebase, Every Screen

Go Explained: Simple Code That Runs Fast