File size: 1,265 Bytes
d17ca98
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
51
52
53
54
55
56
57
from fastapi import FastAPI, HTTPException, Security, status
from fastapi.middleware.cors import CORSMiddleware
from fastapi.middleware.trustedhost import TrustedHostMiddleware
from fastapi.security import OAuth2PasswordBearer
from fastapi.security.api_key import APIKeyHeader
from contextlib import asynccontextmanager

from server.utils.database import get_db

from server.routes.database import router as database_router


@asynccontextmanager
async def lifespan(_):
    yield

app = FastAPI(
    title="Hiago Docs",
    description="This is the documentation for Hiago's API.",
    version="1.0",
    basePath="/v1",
    lifespan=lifespan,
)




app.add_middleware(
    TrustedHostMiddleware,
    allowed_hosts=["*"],
)
origins=["*"]


app.add_middleware(
    CORSMiddleware,
    allow_origins=origins,
    allow_credentials=True,
    allow_methods=["GET", "POST", "PUT", "DELETE"],
    allow_headers=["*"],
)

@app.get("/")
async def app_startup():
    return {"status": "elasticsearch engine running"}


@app.get("/health", status_code=status.HTTP_200_OK)
async def health_check():
    return {"status": "healthy"}


app.include_router(
    database_router,
    tags=["patent_data"],
    prefix="/v1",
)