Complete the code to define a FastAPI route that responds to GET requests at '/items/'.
from fastapi import FastAPI app = FastAPI() @app.get("/items[1]") def read_items(): return {"message": "Items list"}
The trailing slash '/' in the route path means the URL must end with a slash to match this route.
Complete the code to define a FastAPI route that responds to GET requests at '/users' without a trailing slash.
from fastapi import FastAPI app = FastAPI() @app.get("/users[1]") def read_users(): return {"message": "Users list"}
Omitting the trailing slash means the route matches URLs without a slash at the end.
Fix the error in the route decorator to correctly handle requests to '/products/'.
from fastapi import FastAPI app = FastAPI() @app.get("/products[1]") def read_products(): return {"message": "Products list"}
The route must include the trailing slash '/' to match URLs ending with '/products/'.
Complete the code to create a route that matches '/orders' without a trailing slash and returns a JSON message.
from fastapi import FastAPI app = FastAPI() @app.get("/orders") def read_orders(): return {"message": "Orders[1]"}
The route path has no trailing slash, so BLANK_1 is empty. The message adds ' list' to 'Orders' for clarity.
Fill all three blanks to define a route that matches '/customers/' with trailing slash and returns a JSON with key 'name' and value 'Customer'.
from fastapi import FastAPI app = FastAPI() @app.get("/customers[1]") def read_customers(): return {{"[2]": "[3]"}}
The route includes a trailing slash '/'. The returned JSON has key 'name' and value 'Customer'.