0
0
FastAPIframework~20 mins

Uvicorn server basics in FastAPI - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Uvicorn Mastery
Get all challenges correct to earn this badge!
Test your skills under time pressure!
component_behavior
intermediate
1:30remaining
What happens when you run Uvicorn with default settings?
You start a FastAPI app using uvicorn main:app without extra options. What is the behavior of the server?
AThe server runs on localhost at port 8000 but does not reload automatically on code changes.
BThe server runs on all network interfaces at port 80 and reloads automatically on code changes.
CThe server runs on localhost at port 8000 and reloads automatically on code changes.
DThe server runs on all network interfaces at port 8000 but does not reload automatically.
Attempts:
2 left
💡 Hint
Think about the default host, port, and reload behavior of Uvicorn.
📝 Syntax
intermediate
1:30remaining
Which command correctly starts Uvicorn with auto-reload and on all interfaces?
You want to run your FastAPI app with Uvicorn so it reloads on code changes and listens on all network interfaces. Which command is correct?
Auvicorn main:app --reload host=0.0.0.0
Buvicorn main:app --host 0.0.0.0 --reload
Cuvicorn main:app --reload --host 0.0.0.0
Duvicorn main:app --host=localhost --reload
Attempts:
2 left
💡 Hint
Check the correct syntax for flags and their order.
state_output
advanced
2:00remaining
What is the output when Uvicorn fails to bind to port 80?
You run uvicorn main:app --host 0.0.0.0 --port 80 without root privileges on Linux. What error message or behavior will you see?
ARuntimeError: Port 80 is already in use
BPermissionError: [Errno 13] Permission denied
CSyntaxError: invalid port number
DThe server starts successfully on port 80
Attempts:
2 left
💡 Hint
Ports below 1024 require special permissions on Unix systems.
🔧 Debug
advanced
2:00remaining
Why does Uvicorn not reload when using --reload with a custom app import path?
You run uvicorn myproject.app:app --reload but changes in your code do not trigger reload. What is the most likely cause?
AThe server needs to be restarted manually to enable reload.
BThe <code>--reload</code> flag only works with the default <code>main:app</code> import path.
CUvicorn does not support reload on Windows systems.
DThe import path is incorrect or the app is not detected properly.
Attempts:
2 left
💡 Hint
Check if the app path matches your project structure exactly.
🧠 Conceptual
expert
2:30remaining
How does Uvicorn handle multiple worker processes?
You start Uvicorn with --workers 4. What is true about how Uvicorn manages these workers?
AUvicorn starts 4 separate processes, each running the app independently to handle requests concurrently.
BUvicorn runs a single process with 4 threads to handle requests concurrently.
CUvicorn runs 4 processes but shares the same memory space for app state.
DUvicorn cannot run multiple workers; the flag is ignored.
Attempts:
2 left
💡 Hint
Think about how Python handles concurrency with processes vs threads.