+12
-2
@@ -4,9 +4,11 @@ from __future__ import annotations
|
||||
|
||||
import logging
|
||||
from contextlib import asynccontextmanager
|
||||
from pathlib import Path
|
||||
|
||||
from fastapi import FastAPI, Request
|
||||
from fastapi.responses import JSONResponse
|
||||
from fastapi.responses import FileResponse, JSONResponse
|
||||
from fastapi.staticfiles import StaticFiles
|
||||
|
||||
import app.models # noqa: F401 注册全部表
|
||||
from app.api import router
|
||||
@@ -27,8 +29,16 @@ async def lifespan(_: FastAPI):
|
||||
stop_scheduler()
|
||||
|
||||
|
||||
app = FastAPI(title="DePIN 算力节点与任务调度", version="1.0.0", lifespan=lifespan)
|
||||
WEB_DIR = Path(__file__).resolve().parent.parent / "web"
|
||||
|
||||
app = FastAPI(title="HyperNode-AI", version="1.0.0", lifespan=lifespan)
|
||||
app.include_router(router)
|
||||
app.mount("/static", StaticFiles(directory=WEB_DIR), name="static")
|
||||
|
||||
|
||||
@app.get("/")
|
||||
def console() -> FileResponse:
|
||||
return FileResponse(WEB_DIR / "index.html")
|
||||
|
||||
|
||||
@app.exception_handler(AppError)
|
||||
|
||||
Reference in New Issue
Block a user