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 is happiest on a VPS or a platform service - some shared hosts can run Python apps, but support is limited and setup is fiddly, so on shared hosting PHP is usually 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.

Common beginner mistakes

  • Skipping the virtual environment. Create one per project with python -m venv .venv so packages don't clash between projects.
  • Keeping data in Python variables. A global list works in development, but production servers run several worker processes that don't share memory - and restarts wipe it. Use a database.
  • Debug mode in production. Flask's interactive debugger lets anyone who can trigger an error run code on your server.
  • Circular imports as the app grows. Use blueprints and an application factory (create_app()) to keep modules independent.
  • Hard-coding URLs. Use url_for() so links keep working when routes change.

Getting it online

Flask apps run behind a production WSGI server such as gunicorn. Render and Railway deploy straight from GitHub, and PythonAnywhere is a beginner-friendly host with a free tier and persistent files. Our Flask deployment guide covers the whole process, including the errors people usually hit.


← Back to Stack Picker All primers Compare languages