Coverage for docs_src / custom_response / tutorial004_py310.py: 100%

9 statements  

« prev     ^ index     » next       coverage.py v7.13.3, created at 2026-02-12 18:15 +0000

1from fastapi import FastAPI 1abc

2from fastapi.responses import HTMLResponse 1abc

3 

4app = FastAPI() 1abc

5 

6 

7def generate_html_response(): 1abc

8 html_content = """ 1def

9 <html> 

10 <head> 

11 <title>Some HTML in here</title> 

12 </head> 

13 <body> 

14 <h1>Look ma! HTML!</h1> 

15 </body> 

16 </html> 

17 """ 

18 return HTMLResponse(content=html_content, status_code=200) 1def

19 

20 

21@app.get("/items/", response_class=HTMLResponse) 1abc

22async def read_items(): 1abc

23 return generate_html_response() 1def