Premier League Predictor: FastAPI & PostgreSQL — Chapter 1, Exercise 3 ==================================================== TASK Set up the pl_predictor PostgreSQL database and a working FastAPI project connected to it yourself, confirm /api/health responds, then check /docs in a browser and write one sentence on what it's showing you before any real route exists. SOLUTION Steps to complete this exercise: 1. Create and activate a virtual environment, then install the dependencies: python -m venv venv source venv/bin/activate # venv\Scripts\activate on Windows pip install fastapi uvicorn[standard] sqlalchemy psycopg2-binary python-dotenv 2. Create the database in psql (or a preferred PostgreSQL client): CREATE DATABASE pl_predictor WITH ENCODING 'UTF8'; 3. Create main.py exactly as shown in the chapter, with the single /api/health route. 4. Start the app: uvicorn main:app --reload 5. Visit http://localhost:8000/api/health in a browser — it should return {"status": "ok"}. 6. Visit http://localhost:8000/docs — even though only one route exists, /docs already shows a fully working, interactive page for it: the route's path, its HTTP method, and a "Try it out" button that actually calls the endpoint and shows a real response, live in the browser. One-sentence answer for the write-up: /docs is showing a real, interactive API explorer generated automatically from the app's own route definitions — proof that FastAPI's documentation isn't a separate thing to write later, it already exists the moment a route does. WHY THIS WORKS AS AN ANSWER ---------------------------- It walks through every real setup step in order (environment, database, app file, running the server, confirming both the health route and /docs), and closes with a one-sentence answer that correctly identifies /docs as automatically generated from the route itself rather than a separately maintained document — the actual point of the exercise.