Practice - 5 Tasks
Answer the questions below
1fill in blank
easyComplete the code to import the Uvicorn server module.
FastAPI
import [1]
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Importing 'fastapi' instead of 'uvicorn'.
Using unrelated modules like 'requests' or 'flask'.
✗ Incorrect
The uvicorn module is used to run the FastAPI app with the Uvicorn server.
2fill in blank
mediumComplete the code to run the FastAPI app named 'app' with Uvicorn.
FastAPI
uvicorn.run([1], host="127.0.0.1", port=8000)
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Passing the app name as a string instead of the variable.
Using a capitalized or incorrect variable name.
✗ Incorrect
You pass the FastAPI app instance app directly to uvicorn.run().
3fill in blank
hardFix the error in the code to run Uvicorn with auto-reload enabled.
FastAPI
uvicorn.run(app, host="127.0.0.1", port=8000, [1]=True)
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using incorrect parameter names like 'auto_reload' or 'debug'.
Misspelling the parameter name.
✗ Incorrect
The correct parameter to enable auto-reload in Uvicorn is reload=True.
4fill in blank
hardFill both blanks to run Uvicorn on all network interfaces with debug mode off.
FastAPI
uvicorn.run(app, host=[1], port=[2], debug=False)
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using localhost IP instead of all interfaces.
Choosing a non-standard port without reason.
✗ Incorrect
To listen on all interfaces, use host="0.0.0.0". The default port is usually 8000.
5fill in blank
hardFill all three blanks to run Uvicorn with app instance, host, and port from variables.
FastAPI
uvicorn.run([1], host=[2], port=[3])
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using undefined app variable names.
Passing host without quotes.
Using default port instead of specified.
✗ Incorrect
Use the app variable app, host string "localhost", and port number 9000 to run Uvicorn.