rrefactor: change admin and public API routers to compatible vercel
This commit is contained in:
1 parent
f4e0ae4a1f
commit
ad92974ccc
9 files changed
+17
-10
No files matched your search
@@ -2,9 +2,9 @@
|
||||
|
||||
from fastapi import APIRouter
|
||||
|
||||
from app.api.v1.admin.cache import router as cache_router
|
||||
from app.api.v1.admin.config import router as config_router
|
||||
from app.api.v1.admin.token import router as tokens_router
|
||||
from app.api.v1.admin_api.cache import router as cache_router
|
||||
from app.api.v1.admin_api.config import router as config_router
|
||||
from app.api.v1.admin_api.token import router as tokens_router
|
||||
|
||||
router = APIRouter()
|
||||
|
||||
File renamed without changes.
File renamed without changes.
File renamed without changes.
@@ -2,9 +2,9 @@
|
||||
|
||||
from fastapi import APIRouter
|
||||
|
||||
from app.api.v1.public.imagine import router as imagine_router
|
||||
from app.api.v1.public.video import router as video_router
|
||||
from app.api.v1.public.voice import router as voice_router
|
||||
from app.api.v1.public_api.imagine import router as imagine_router
|
||||
from app.api.v1.public_api.video import router as video_router
|
||||
from app.api.v1.public_api.voice import router as voice_router
|
||||
|
||||
router = APIRouter()
|
||||
|
||||
File renamed without changes.
File renamed without changes.
File renamed without changes.
@@ -12,7 +12,14 @@ from pathlib import Path
|
||||
|
||||
from dotenv import load_dotenv
|
||||
|
||||
env_file = Path(__file__).parent / ".env"
|
||||
BASE_DIR = Path(__file__).resolve().parent
|
||||
APP_DIR = BASE_DIR / "app"
|
||||
|
||||
# Ensure the project root is on sys.path (helps when Vercel sets a different CWD)
|
||||
if str(BASE_DIR) not in sys.path:
|
||||
sys.path.insert(0, str(BASE_DIR))
|
||||
|
||||
env_file = BASE_DIR / ".env"
|
||||
if env_file.exists():
|
||||
load_dotenv(env_file)
|
||||
|
||||
@@ -30,8 +37,8 @@ from app.api.v1.image import router as image_router # noqa: E402
|
||||
from app.api.v1.files import router as files_router # noqa: E402
|
||||
from app.api.v1.models import router as models_router # noqa: E402
|
||||
from app.services.token import get_scheduler # noqa: E402
|
||||
from app.api.v1.admin import router as admin_router
|
||||
from app.api.v1.public import router as public_router
|
||||
from app.api.v1.admin_api import router as admin_router
|
||||
from app.api.v1.public_api import router as public_router
|
||||
from app.api.pages import router as pages_router
|
||||
from fastapi.staticfiles import StaticFiles
|
||||
|
||||
@@ -118,7 +125,7 @@ def create_app() -> FastAPI:
|
||||
app.include_router(files_router, prefix="/v1/files")
|
||||
|
||||
# 静态文件服务
|
||||
static_dir = Path(__file__).parent / "app" / "static"
|
||||
static_dir = APP_DIR / "static"
|
||||
if static_dir.exists():
|
||||
app.mount("/static", StaticFiles(directory=static_dir), name="static")
|
||||
|
||||
|
||||
Reference in new issue
Block a user