Python (Flask)

The most readable language, with its simplest web framework.

What is it?

Python is a general-purpose programming language famous for reading almost like English — it's consistently ranked the most beginner-friendly language, and it's used everywhere from web servers to data science to automation scripts. Flask is Python's minimalist web framework: it handles the plumbing of receiving web requests and sending responses, and stays out of your way for everything else. A working web server is genuinely five lines of code.


When to use it

Pick Python + Flask when learning is the priority, or when your project might grow into data-heavy territory where Python's ecosystem (pandas, machine learning libraries) is unmatched. Flask is ideal for small-to-medium apps and APIs. Note that Python needs a VPS or a platform service to host — it won't run on classic shared hosting, where PHP is the practical choice. If you're already deep in JavaScript, Node.js saves you learning a second language.


Core concepts
  • Indentation is structure — Python uses indentation instead of braces to group code, which forces readable formatting from day one.
  • Routes — in Flask, you attach a function to a URL with a decorator: @app.route("/about"). Visit the URL, and the function runs.
  • Request and response — form data, query parameters, and JSON arrive on a request object; whatever your function returns becomes the response.
  • Templates — Flask renders HTML with Jinja templates, letting you drop variables and loops into pages: {{ username }}.
  • Virtual environments — each project gets its own isolated set of packages via venv, so dependencies never clash.

A taste of the code
from flask import Flask

app = Flask(__name__)

@app.route("/")
def home():
    return "<h1>Hello from Flask!</h1>"

@app.route("/user/<name>")
def user(name):
    return f"<h1>Hi, {name}!</h1>"

Run flask run and you have a web server: the home page at /, and a dynamic page at /user/anything that greets whoever's in the URL.


Your first steps
  1. Install Python from python.org, then learn the basics — variables, lists, dictionaries, functions, and loops — by writing small scripts.
  2. Create a project folder, set up a virtual environment (python -m venv venv), activate it, and pip install flask.
  3. Copy the hello-world app above into app.py and run it with flask run.
  4. Add a Jinja template and a form — a guestbook or note-taking app is the classic first project.
  5. Store the data in SQLite, which Python supports out of the box with no installation.

← Back to Stack Picker All primers