Complete the code to import the FastAPI class.
from fastapi import [1] app = [1]()
The FastAPI class is imported from fastapi to create the app instance.
Complete the code to define a dependency function that returns a string.
def common_dependency(): return [1]
The dependency returns a string 'shared value' to be used in routes.
Fix the error in the router dependency declaration.
from fastapi import APIRouter, Depends router = APIRouter( dependencies=[Depends([1])] )
The dependency function common_dependency must be passed to Depends in the router.
Fill both blanks to create a route that uses the shared dependency and returns its value.
@router.get("/shared") async def read_shared(value: str = [1]([2])): return {"value": value}
The route parameter uses Depends with the common_dependency function to get the shared value.
Fill all three blanks to include the router in the app with a prefix and shared dependencies.
app.include_router(
router,
prefix=[1],
dependencies=[[2]([3])]
)The router is included with prefix '/users' and the shared dependency declared with Depends(common_dependency).