Recall & Review
beginner
What is FastAPI used for?
FastAPI is a modern web framework for building APIs with Python. It helps create fast and easy-to-use web services.
Click to reveal answer
beginner
Which Python package do you import to start a FastAPI app?You import the FastAPI class from the fastapi package to create your application instance.Click to reveal answer
beginner
What does the @app.get('/') decorator do in FastAPI?
It tells FastAPI to run the function below it when someone visits the root URL ('/') with a GET request.
Click to reveal answer
beginner
How do you run a FastAPI app locally for testing?
You use the command 'uvicorn main:app --reload' in the terminal, where 'main' is your Python file and 'app' is your FastAPI instance.
Click to reveal answer
beginner
What will this FastAPI function return?
@app.get('/')
async def root():
return {"message": "Hello, FastAPI!"}
It returns a JSON response with a key 'message' and value 'Hello, FastAPI!'. The browser or client will see {"message": "Hello, FastAPI!"}.
Click to reveal answer
What is the first step to create a FastAPI app?
✗ Incorrect
You start by importing FastAPI and creating an app instance to build your API.
Which command runs a FastAPI app with auto-reload?
✗ Incorrect
The 'uvicorn main:app --reload' command runs the app and reloads on code changes.
What does the function decorated with @app.get('/') respond to?
✗ Incorrect
The @app.get('/') decorator handles GET requests to the root URL.
What type of data does FastAPI return by default from a function?
✗ Incorrect
FastAPI returns JSON responses by default.
Which Python keyword is used to define an async function in FastAPI?
✗ Incorrect
The 'async' keyword defines an asynchronous function.
Describe the steps to create and run your first FastAPI application.
Think about how you start a web server and respond to a web request.
You got /5 concepts.
Explain what happens when you visit the root URL of a FastAPI app with a simple @app.get('/') function.
Imagine you open a webpage and the server sends back a message.
You got /4 concepts.