mirror of
https://github.com/stardrophere/InsightRadar.git
synced 2026-06-06 00:00:05 +08:00
修改成由后端处理前端的静态文件
This commit is contained in:
+10
-1
@@ -1,9 +1,10 @@
|
||||
# app/main.py
|
||||
import logging
|
||||
import os
|
||||
from fastapi.responses import FileResponse
|
||||
import httpx
|
||||
from contextlib import asynccontextmanager
|
||||
from fastapi import FastAPI
|
||||
from fastapi import FastAPI, staticfiles
|
||||
from fastapi.middleware.cors import CORSMiddleware
|
||||
from dotenv import load_dotenv
|
||||
|
||||
@@ -112,6 +113,14 @@ app.add_middleware(
|
||||
# 版本控制
|
||||
app.include_router(api_router, prefix="/api/v1")
|
||||
|
||||
# 把目录改成static对应我们放dist内容的路径就可以
|
||||
app.mount("/", staticfiles.StaticFiles(directory="app/static", html=True), name="static")
|
||||
|
||||
# 只需要保留API的优先匹配,catch_all可以简化成这样
|
||||
@app.get("/api/{full_path:path}")
|
||||
async def api_not_found(full_path: str):
|
||||
return {"detail": "API Not Found"}
|
||||
|
||||
# 健康检查
|
||||
@app.get("/", tags=["健康检查"])
|
||||
async def root():
|
||||
|
||||
Reference in New Issue
Block a user