indexcalculation/main.py

59 lines
1.4 KiB
Python
Raw Normal View History

2022-10-13 19:04:16 +08:00
import uvicorn
2022-10-13 17:07:52 +08:00
from fastapi import FastAPI
2022-10-09 13:43:06 +08:00
from fastapi.middleware.cors import CORSMiddleware
2022-10-13 19:04:16 +08:00
from Indicators.Capital import capital_router
2022-10-13 17:07:52 +08:00
from Indicators.Profit import profit_router
from Indicators.Debt import debt_router
2022-09-26 00:02:17 +08:00
2022-10-11 09:49:50 +08:00
app = FastAPI(
title="指标函数计算接口",
2022-10-13 17:07:52 +08:00
description="1.发送计算请求,返回结果数值\n"
"2.发送描述请求,返回指标描述信息",
2022-10-11 09:49:50 +08:00
version="v1.0.0"
)
2022-09-26 00:02:17 +08:00
2022-10-09 13:43:06 +08:00
app.add_middleware(
CORSMiddleware,
allow_origins=["*"],
allow_credentials=True,
allow_methods=["*"],
allow_headers=["*"],
)
2022-10-13 17:07:52 +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-13 18:03:57 +08:00
PREFIX = "/api/index_function"
2022-10-13 17:07:52 +08:00
app.include_router(profit_router, prefix=PREFIX)
app.include_router(debt_router, prefix=PREFIX)
2022-10-13 19:04:16 +08:00
app.include_router(capital_router, prefix=PREFIX)
2022-10-13 17:07:52 +08:00
# Income.router,
# Flows.router,
# Capital.router,
# debt_router,
# Operating.router,
# Growth.router,
# Business.router,
# Qualification.router,
# Industry.router,
# Green.router,
# Judicial.router,
# Compliance.router,
# PublicOpinion.router,
# Other.router,
2022-10-13 19:04:16 +08:00
if __name__ == "__main__":
uvicorn.run(app, host="127.0.0.1", port=8001)