from fastapi import FastAPI app = FastAPI() @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, }