Web framework
A library that handles the plumbing of web requests so you can focus on your app's logic. Flask and Django are examples.
A web framework takes care of the repetitive parts of serving a website — listening for HTTP requests, matching URLs to code, and building responses — so you write only the parts unique to your app. You map a URL to a function, and the framework runs it when a request arrives.
Flask is a small, beginner-friendly Python framework; Django is a larger, batteries-included one. Both let your Python code answer requests with web pages.
# A minimal Flask app
from flask import Flask
app = Flask(__name__)
@app.route("/") # map a URL to a function
def home():
return "Hello, world!"
Where this shows up in real Python
Web frameworks (Flask, Django) handle the repetitive parts of serving a site — routing, templates, requests — so you write the interesting bits.
Commonly used Web framework tools
@app.route('/')— map a URL to a functionrender_template('page.html')— fill an HTML templaterequest— read the incoming requestreturn— the response sent back to the browser
Official documentation: Flask Documentation