Add support for app.frontend("/", directory="dist") and router.frontend("/", directory="dist") (#15800)

This commit is contained in:
Sebastián Ramírez
2026-06-20 02:20:49 +02:00
committed by GitHub
parent f1d750fdda
commit 4d3dc78b26
15 changed files with 1649 additions and 5 deletions

View File

View File

@@ -0,0 +1,5 @@
from fastapi import FastAPI
app = FastAPI()
app.frontend("/", directory="dist")

View File

@@ -0,0 +1,5 @@
from fastapi import FastAPI
app = FastAPI()
app.frontend("/", directory="dist", fallback="index.html")

View File

@@ -0,0 +1,5 @@
from fastapi import FastAPI
app = FastAPI()
app.frontend("/", directory="dist", fallback="404.html")

View File

@@ -0,0 +1,7 @@
from fastapi import APIRouter, FastAPI
app = FastAPI()
router = APIRouter()
router.frontend("/", directory="dist", fallback="index.html")
app.include_router(router, prefix="/app")

View File

@@ -0,0 +1,5 @@
from fastapi import FastAPI
app = FastAPI()
app.frontend("/", directory="dist", fallback=None)

View File

@@ -0,0 +1,5 @@
from fastapi import FastAPI
app = FastAPI()
app.frontend("/", directory="dist", check_dir=False)