0
0
FastAPIframework~5 mins

FastAPI installation and setup - Cheat Sheet & Quick Revision

Choose your learning style9 modes available
Recall & Review
beginner
What command do you use to install FastAPI?
You use pip install fastapi to install FastAPI.
Click to reveal answer
beginner
Why do you also need to install an ASGI server like Uvicorn when using FastAPI?
FastAPI is a framework, but it needs an ASGI server like Uvicorn to run your app and handle web requests.
Click to reveal answer
beginner
What is the command to install Uvicorn with recommended extras?
You run pip install "uvicorn[standard]" to install Uvicorn with useful extras for production.
Click to reveal answer
beginner
How do you start a FastAPI app using Uvicorn from the command line?
Use uvicorn main:app --reload where main is your Python file and app is your FastAPI instance. The --reload option restarts the server on code changes.
Click to reveal answer
beginner
What is the minimal FastAPI app code to test your setup?
```python
from fastapi import FastAPI
app = FastAPI()

@app.get("/")
async def read_root():
    return {"Hello": "World"}
```
Click to reveal answer
Which command installs FastAPI?
Apip install uvicorn
Bpip install flask
Cpip install fastapi
Dpip install django
What role does Uvicorn play in FastAPI setup?
AIt is an ASGI server to run the app
BIt is a database
CIt is a frontend framework
DIt is a testing tool
What does the --reload option do when running Uvicorn?
ARestarts server on code changes
BEnables debugging mode
CRuns server in production mode
DDisables logging
Which file and variable do you specify to run a FastAPI app with Uvicorn?
Aserver.py:fastapi
Bapp.py:main
Cfilename:app
Dmain:app
What is the first step after installing FastAPI and Uvicorn to see your app running?
AInstall a database
BWrite a FastAPI app code
CRun <code>python main.py</code>
DOpen a browser
Describe the steps to install and run a basic FastAPI app.
Think about installation, coding, and running the server.
You got /4 concepts.
    Explain why you need both FastAPI and Uvicorn to run a web app.
    One builds, the other runs.
    You got /3 concepts.