Coverage for docs_src/templates/tutorial001.py: 100%
10 statements
« prev ^ index » next coverage.py v7.6.1, created at 2024-08-08 03:53 +0000
« prev ^ index » next coverage.py v7.6.1, created at 2024-08-08 03:53 +0000
1from fastapi import FastAPI, Request 1abcde
2from fastapi.responses import HTMLResponse 1abcde
3from fastapi.staticfiles import StaticFiles 1abcde
4from fastapi.templating import Jinja2Templates 1abcde
6app = FastAPI() 1abcde
8app.mount("/static", StaticFiles(directory="static"), name="static") 1abcde
11templates = Jinja2Templates(directory="templates") 1abcde
14@app.get("/items/{id}", response_class=HTMLResponse) 1abcde
15async def read_item(request: Request, id: str): 1abcde
16 return templates.TemplateResponse( 1abcde
17 request=request, name="item.html", context={"id": id}
18 )