Initial commit
This commit is contained in:
28
app/main.py
Normal file
28
app/main.py
Normal file
@@ -0,0 +1,28 @@
|
||||
from fastapi import FastAPI
|
||||
from fastapi.middleware.cors import CORSMiddleware
|
||||
from app.api.login import router as login_router
|
||||
from app.api.submit_record import router as submit_record_router
|
||||
from app.api.db import Base, engine
|
||||
from app.settings import API_V1_STR
|
||||
|
||||
# 创建数据库表
|
||||
Base.metadata.create_all(bind=engine)
|
||||
|
||||
app = FastAPI(
|
||||
title="PBMDB API",
|
||||
description="微生物数据库后端API",
|
||||
version="1.0.0"
|
||||
)
|
||||
|
||||
# 配置CORS
|
||||
app.add_middleware(
|
||||
CORSMiddleware,
|
||||
allow_origins=["*"], # 在生产环境中应该设置具体的前端域名
|
||||
allow_credentials=True,
|
||||
allow_methods=["*"],
|
||||
allow_headers=["*"],
|
||||
)
|
||||
|
||||
# 包含路由
|
||||
app.include_router(login_router, prefix=API_V1_STR, tags=["login"])
|
||||
app.include_router(submit_record_router, prefix=API_V1_STR, tags=["submit_record"])
|
||||
Reference in New Issue
Block a user