Module 10 ยท Pydantic & FastAPI โ Lesson 3 of 4 ยท ~9 min
FastAPI hello โ the real main.py
Familiar decorator, new superpower
@app.route("/") from Flask and FastAPI's @app.get("/") look almost identical โ same decorator idea from module 16, same "a function handles a request" model from Flask. The difference is what happens to the function's parameters.
In Flask, everything from the request is a string you convert by hand (float(request.args.get(...)), remember module 19?). In FastAPI, you write a type hint on the parameter, and FastAPI converts AND validates it for you โ using Pydantic under the hood.