fastapitest/main.py

48 lines
685 B
Python
Executable File

from fastapi import FastAPI
from uvicorn.middleware.proxy_headers import ProxyHeadersMiddleware
app = FastAPI()
app.add_middleware(
ProxyHeadersMiddleware, trusted_hosts=[None]
)
@app.get("/f1")
async def f1():
return {
"name": "f1",
"slash": False,
}
@app.get("/d1")
async def f1():
return {
"name": "d1",
"slash": False,
}
@app.get("/d1/f2")
async def f1():
return {
"name": "f2",
"slash": False,
}
@app.get("/d2/")
async def f1():
return {
"name": "d2",
"slash": True,
}
@app.get("/d2/f3")
async def f1():
return {
"name": "f3",
"slash": False,
}