DAY 04 of 12
App plus data
Talk HTTP, keep the data in one file — then serve a real API
You can do… by end of day
- Read and produce HTTP requests/responses: methods, headers, status codes.
- Build a Flask app with routes and JSON APIs, driven with
curl. - Use SQLite — tables, keys,
JOINs, indexes — with every query shown with its real result. - Serve a small Flask app publicly on port 80 and open it in a browser.
Deliverable
A live Flask JSON API backed by SQLite, at a public URL.
Big-picture hook
The right side of the diagram — the APP and the SQLITE box — and you built it. Tomorrow you give it a history and reproducible dependencies.
Concepts what you'll understand
- Anatomy of a request/response (see it with
curl -v): request line, headers, body; status line, headers, body. - Methods (GET/POST/PUT/DELETE) and the status codes you'll meet daily (200, 201, 301, 400, 401, 404, 500).
- Flask:
app.py,@app.route,request.get_json(),jsonify— “just” the request/response loop, organized. - SQLite: a database = one file, no server process. Tables, rows, primary keys, foreign keys;
SELECT/INSERT/UPDATE/DELETE; JOINs and indexes. - The frontend↔backend contract: “GET
/api/itemsreturns a JSON list.” That's the whole game.
The lab hands-on, ends with something live
- Hello route: a Flask app with a couple of routes; hit them with
curland read the responses. - First table: create a SQLite database, a table, insert rows, and query them back.
- Joins lab: two related tables, a
JOIN, and an index that makes a query fast. - Serve it publicly: run a tiny Flask API on port 80 and open the public URL — your first real, addressable API.
Want this in another format? All formats