I have a FastAPI app that returns an HTMLResponse
. The code is simple and straightforward as the examples in FastAPI's documentation. The response works fine, but Swagger UI displays the raw HTML content. Is there a way to display the actual HTML page?
FastAPI app:
from fastapi import FastAPI
from fastapi.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)