38 lines
1.1 KiB
Python
38 lines
1.1 KiB
Python
import uvicorn
|
|
from fastapi import FastAPI
|
|
from fastapi.middleware.cors import CORSMiddleware
|
|
from fastapi.staticfiles import StaticFiles
|
|
from app.api.endpoints import auth, users, meetings
|
|
from app.core.config import UPLOAD_DIR, API_CONFIG
|
|
import os
|
|
|
|
app = FastAPI(
|
|
title="iMeeting API",
|
|
description="智慧会议系统API",
|
|
version="1.0.0"
|
|
)
|
|
|
|
# 添加CORS中间件
|
|
app.add_middleware(
|
|
CORSMiddleware,
|
|
allow_origins=API_CONFIG['cors_origins'],
|
|
allow_credentials=True,
|
|
allow_methods=["*"],
|
|
allow_headers=["*"],
|
|
)
|
|
|
|
# 静态文件服务 - 提供音频文件下载
|
|
if UPLOAD_DIR.exists():
|
|
app.mount("/uploads", StaticFiles(directory=str(UPLOAD_DIR)), name="uploads")
|
|
|
|
# 包含API路由
|
|
app.include_router(auth.router, prefix="/api", tags=["Authentication"])
|
|
app.include_router(users.router, prefix="/api", tags=["Users"])
|
|
app.include_router(meetings.router, prefix="/api", tags=["Meetings"])
|
|
|
|
@app.get("/")
|
|
def read_root():
|
|
return {"message": "Welcome to iMeeting API"}
|
|
|
|
if __name__ == "__main__":
|
|
uvicorn.run(app, host=API_CONFIG['host'], port=API_CONFIG['port']) |