Flask Course: Start Here: How the Web Works
What happens when you open a web page: clients and servers, URLs, HTTP requests and responses, methods and status codes, HTML, CSS and JavaScript, and where Flask fits among Python web frameworks.
Why this course?
A model in a notebook helps nobody else. To let people use it, you put it behind a web app or an API and run it on a server. This course takes you from your first Flask page to a tested, containerised, monitored app running in the cloud, with a machine-learning model inside.
You need the Python course and the basics of SQL. The model-serving topics also use a little scikit-learn from the Machine Learning course.
Clients, servers and HTTP
When you open a web page, your browser (the client) sends a request over the internet to a server, a program waiting for requests. The server sends back a response. They talk in HTTP (with HTTPS, the same conversation is encrypted).
- A URL such as
https://clinic.example.com/patients/7?view=fullhas a scheme (https), a host (clinic.example.com), a path (/patients/7) and a query string (?view=full). - Every request has a method: GET to read, POST to create or submit, PUT/PATCH to update, DELETE to remove.
- Requests and responses carry headers (extra information such as
Content-Type: application/jsonor a login token) and an optional body (form data, JSON, HTML). - Every response has a status code: 2xx success (200 OK, 201 Created, 204 No Content), 3xx redirect, 4xx the client made a mistake (400 Bad Request, 401 not logged in, 403 not allowed, 404 Not Found, 422 invalid data, 429 too many requests), 5xx the server failed (500).
Try it: send requests to a tiny clinic API
Pick a request and press Send. You will see the exact text that travels to the server and back. Try the ones that fail too: the status codes tell you why.
Interactive: this part runs in your browser.
HTML, CSS and JavaScript in one minute
- HTML is the content and structure of a page: headings, paragraphs, links, forms.
- CSS is how it looks: colours, fonts, layout.
- JavaScript runs in the browser to make pages interactive, and can call your API in the background (this is how most modern apps work).
Your Flask app can send HTML pages (a website) or JSON (an API that other programs, phone apps or JavaScript call), or both. You only need enough HTML to build simple forms; this course gives you the templates.
Flask, Django or FastAPI?
| Framework | Style | Good for |
|---|---|---|
| Flask | small core, add what you need | learning, small and medium apps, ML demos and APIs |
| Django | "batteries included": database models, admin site, logins built in | large websites with many pages and users |
| FastAPI | APIs with automatic validation and documentation from type hints; async | JSON APIs and model serving |
The ideas (routes, requests, responses, templates, validation) are the same in all three. Flask is the clearest way to learn them, and it is widely used in industry and research.
Quiz
1. Which HTTP method should a form that creates a new patient record use?
2. Your API returns 404. What does it mean?
3. In https://site.com/search?q=flask, what is q=flask?
4. Which status code means "the server itself failed"?
📚 Further reading
Trusted, mostly free sources: official documentation, well-known textbooks and courses. When you want to confirm or go deeper on anything here, start with these.
- MDN Web Docs: HTTP ↗ clear reference on requests, responses, methods and status codes
- Flask documentation ↗ the official docs, including the Quickstart