indexstore/main.py

36 lines
849 B
Python
Raw Normal View History

2022-09-30 15:00:45 +08:00
from fastapi import FastAPI, Header, Depends
2022-10-09 11:12:47 +08:00
from fastapi.middleware.cors import CORSMiddleware
2022-09-30 15:00:45 +08:00
from Indicator import indicator
app = FastAPI()
2022-10-09 11:12:47 +08:00
app.add_middleware(
CORSMiddleware,
allow_origins=["*"],
allow_credentials=True,
allow_methods=["*"],
allow_headers=["*"],
)
2022-09-30 15:00:45 +08:00
# async def get_token_header(authorization: str = Header(...)):
# """
# 获取Token并验证
# :param authorization:
# :return: openid
# """
# token = authorization.split(' ')[-1] # 获取token
# openid = auth_token(token) # 验证token
# if not openid:
# raise HTTPException(status_code=400, detail="无效Token")
2022-10-09 10:31:00 +08:00
# 路由
2022-09-30 15:00:45 +08:00
app.include_router(
indicator.router,
2022-10-09 14:19:14 +08:00
prefix="/api/002/indicator_storehouse",
2022-09-30 15:00:45 +08:00
# dependencies=[Depends(get_token_header)],
responses={404: {"description": "Not found"}},
)