Sitemap

Web Frameworks in Python —

4 min readOct 22, 2026

--

Imagine you want to build your own website using Python. You want users to open your website, click buttons, fill out forms, and see information. But writing every part from scratch would take a lot of time.

This is where a web framework in Python becomes your helper!

1. The story: Welcome to Python City

Press enter or click to view image in full size

Imagine a developer named Alex who wants to build an online bookstore called Python Books.

At first, Alex has Python code, but no complete system for handling website requests, displaying pages, or managing URLs.

Then Alex discovers a web framework — a collection of ready-made tools that helps developers build web applications more easily.

2. How does a web framework work?

Press enter or click to view image in full size

Think of a web framework as the manager of a restaurant.

  • Customer: The user who opens a website.
  • Waiter: The web request that carries the user’s request.
  • Manager: The Python web framework that decides what should happen.
  • Kitchen: The Python code that processes the request.
  • Served meal: The response sent back to the user’s browser.

The process looks like this:

1. Browser

User opens /books

2. Python Web Framework

Finds the matching URL route

3. Python Code

Prepares the list of books

4. Browser Response

Displays the books page

3. Your first Python web framework

Let’s use Flask, a lightweight Python web framework, to create a simple website.

Get Raveenanagar’s stories in your inbox

Join Medium for free to get updates from this writer.

Example: app.py

from flask import Flaskapp = Flask(__name__)@app.route("/")def home():    return "Welcome to Python Books!"if __name__ == "__main__":    app.run(debug=True)

Let’s understand the story behind the code

  • Flask(__name__) creates your web application.
  • @app.route("/") tells Flask which URL should open the home page.
  • def home() defines the Python function that handles the request.
  • return "Welcome to Python Books!" sends a response to the browser.
  • app.run(debug=True) starts a development server for testing.

Before running this example, install Flask with pip install flask.

4. Three popular Python web frameworks

Press enter or click to view image in full size

Flask — The small shop

Easy to start with and flexible. Great for learning web development, small applications, and APIs.

Django — The big shopping mall

Includes many built-in tools, such as an admin interface, database support, and authentication. Useful for larger applications.

FastAPI — The fast delivery service

Designed especially for building APIs, with support for asynchronous programming and automatic API documentation.

5. What can you build with Python web frameworks?

Press enter or click to view image in full size

Online bookstore

Display books and manage orders.

Press enter or click to view image in full size

Learning website

Courses, lessons, and quizzes.

Press enter or click to view image in full size

Weather app

Show weather data from an API.

Press enter or click to view image in full size

Blog website

Publish articles and stories.

6. Remember the lesson

A Python web framework is like a ready-made toolkit for building websites. It helps you handle requests, define URLs, generate responses, and connect your application to databases and other services.

Your learning path: Python basics → Flask → HTML and CSS → databases → build a small web application → explore Django or FastAPI.

Press enter or click to view image in full size

--

--