Return main HTML page - Web development with Python FastAPI
Keyboard shortcuts
Press ← or → to navigate between chapters
Press S or / to search in the book
Press ? to show this help
Press Esc to hide this help
Return main HTML page
from fastapi import FastAPI, Response
app = FastAPI()
@app.get("/")
async def root():
data = '<a href="/hello">hello</a>'
return Response(content=data, media_type="text/html")
@app.get("/hello")
async def hello():
return {"message": "Hello World"}