File size: 906 Bytes
54c2a57
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
from fastapi import FastAPI
from fastapi.middleware.cors import CORSMiddleware

from app.core.config import settings
from app.api.endpoints import analysis

app = FastAPI(
    title="Sentiment Analysis API",
    description="API for analyzing sentiment of trending topics.",
    version="1.0.0",
    docs_url="/docs",
    redoc_url="/redoc"
)

app.add_middleware(
    CORSMiddleware,
    allow_origins=["*"],
    allow_credentials=True,
    allow_methods=["*"],
    allow_headers=["*"]
)

app.include_router(analysis.router, prefix=f"{settings.API_PREFIX}{settings.API_VERSION}", tags=["Analysis"])


@app.get("/", tags=["Root"])
def read_root() -> dict:
    """
    Root endpoint to check if the API is running.
    """
    return {"message": "Welcome to the Sentiment Analysis API"}


if __name__ == '__main__':
    import uvicorn

    uvicorn.run("app.main:app", host='0.0.0.0', port=8000, reload=True)