mirror of
https://github.com/fastapi/fastapi.git
synced 2026-04-07 08:35:52 -04:00
📝 Add docs for custom response
This commit is contained in:
19
docs/tutorial/src/custom-response/tutorial003.py
Normal file
19
docs/tutorial/src/custom-response/tutorial003.py
Normal file
@@ -0,0 +1,19 @@
|
||||
from fastapi import FastAPI
|
||||
from starlette.responses import HTMLResponse
|
||||
|
||||
app = FastAPI()
|
||||
|
||||
|
||||
@app.get("/items/")
|
||||
async def read_items():
|
||||
html_content = """
|
||||
<html>
|
||||
<head>
|
||||
<title>Some HTML in here</title>
|
||||
</head>
|
||||
<body>
|
||||
<h1>Look ma! HTML!</h1>
|
||||
</body>
|
||||
</html>
|
||||
"""
|
||||
return HTMLResponse(content=html_content, status_code=200)
|
||||
Reference in New Issue
Block a user