-
Notifications
You must be signed in to change notification settings - Fork 1
/
main.py
51 lines (44 loc) · 1.62 KB
/
main.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
# Copyright 2023-2024 Broadcom
# SPDX-License-Identifier: Apache-2.0
from concurrent.futures import ThreadPoolExecutor
from datetime import datetime
import uvicorn
from fastapi import FastAPI, BackgroundTasks
from starlette.middleware.cors import CORSMiddleware
from src.config import logger
from src.utils.env import _env
from src.db.create_db import create_db
from src.routers.file import router as record_router
from src.routers.retrieval import router as retrieval_router
from src.routers.summarize import router as summarize_router
from src.routers.convert import router as convert_router
from src.routers.metadata import router as meta_router
from src.routers.multidoc import router as multi_router
from src.routers.model import router as model_router
from src.routers.basic_auth import router as user_router
app = FastAPI()
origins = ["*"]
app.add_middleware(
CORSMiddleware,
allow_origins=origins,
allow_methods=["*"],
allow_headers=["*"],
)
# health checking
@app.get("/health")
async def health_check():
return {"code": 200, "msg": datetime.now().strftime("%d-%m-%Y %H:%M:%S")}
app.include_router(summarize_router)
app.include_router(retrieval_router)
app.include_router(record_router)
app.include_router(convert_router)
app.include_router(meta_router)
app.include_router(multi_router)
app.include_router(model_router)
app.include_router(user_router)
if __name__ == '__main__':
server_config = _env.get_server_values()
serverhost = str(server_config['HOST'])
serverport = int(server_config['PORT'])
create_db()
uvicorn.run("main:app", host=serverhost, port=serverport, reload=False, log_level="info")