fix: 接口不再把页面当成运行面板数据
This commit is contained in:
+3
-1
@@ -5,7 +5,7 @@ from pathlib import Path
|
||||
|
||||
from contextlib import asynccontextmanager
|
||||
|
||||
from fastapi import FastAPI
|
||||
from fastapi import FastAPI, HTTPException
|
||||
from fastapi.responses import FileResponse, JSONResponse
|
||||
from fastapi.staticfiles import StaticFiles
|
||||
|
||||
@@ -50,6 +50,8 @@ def create_app() -> FastAPI:
|
||||
|
||||
@application.get("/{path:path}")
|
||||
def pages(path: str) -> FileResponse:
|
||||
if path == "api" or path.startswith("api/"):
|
||||
raise HTTPException(status_code=404, detail="接口不存在")
|
||||
target = WEB_DIST / path
|
||||
if path and target.is_file():
|
||||
return FileResponse(target)
|
||||
|
||||
Reference in New Issue
Block a user