0
0
FastAPIframework~10 mins

FastAPI installation and setup - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to install FastAPI using pip.

FastAPI
pip install [1]
Drag options to blanks, or click blank then click option'
Arequests
Bdjango
Cfastapi
Dflask
Attempts:
3 left
💡 Hint
Common Mistakes
Installing the wrong package like django or flask.
Forgetting to use pip before the package name.
2fill in blank
medium

Complete the code to install the ASGI server needed to run FastAPI.

FastAPI
pip install [1]
Drag options to blanks, or click blank then click option'
Auvicorn
Bwaitress
Cgunicorn
Dhypercorn
Attempts:
3 left
💡 Hint
Common Mistakes
Installing gunicorn which is for WSGI apps.
Using servers not compatible with ASGI.
3fill in blank
hard

Fix the error in the FastAPI app import statement.

FastAPI
from [1] import FastAPI
app = FastAPI()
Drag options to blanks, or click blank then click option'
Afastapi
BfastAPI
CFastAPI
DFastapi
Attempts:
3 left
💡 Hint
Common Mistakes
Using capital letters in the module name.
Trying to import from 'FastAPI' instead of 'fastapi'.
4fill in blank
hard

Fill both blanks to create a basic FastAPI app and run it with uvicorn.

FastAPI
from fastapi import FastAPI
app = FastAPI()

if __name__ == "__main__":
    import [1]
    [2].run(app, host="127.0.0.1", port=8000)
Drag options to blanks, or click blank then click option'
Auvicorn
Bfastapi
Capp
Dflask
Attempts:
3 left
💡 Hint
Common Mistakes
Importing the wrong module to run the app.
Using the app variable instead of the server module to run.
5fill in blank
hard

Fill all three blanks to create a FastAPI app with a root path that returns a welcome message.

FastAPI
from fastapi import FastAPI
app = FastAPI()

@app.[1]("/")
def read_root():
    return [2]([3]: "Welcome to FastAPI!")
Drag options to blanks, or click blank then click option'
Aget
Bdict
C"message"
Dpost
Attempts:
3 left
💡 Hint
Common Mistakes
Using @app.post instead of @app.get for the root path.
Returning a string directly instead of a dictionary.
Missing quotes around the dictionary key.