-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathapp.py
More file actions
60 lines (45 loc) · 2.56 KB
/
app.py
File metadata and controls
60 lines (45 loc) · 2.56 KB
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
58
59
60
import uvicorn
from fastapi import FastAPI
from fastapi.responses import PlainTextResponse
from src.config.settings import get_settings
from src.logger.logger import get_logger
from src.routers import router_generator
from fastapi.middleware.cors import CORSMiddleware
settings = get_settings()
logger = get_logger(__file__)
ascii_art ="""
░░ ░░░ ░░░░░░░░░ ░░░ ░░ ░░░ ░░ ░░ ░░░░ ░░░ ░░░ ░░░ ░░
▒ ▒▒▒▒ ▒▒▒▒▒ ▒▒▒▒▒▒▒▒▒▒▒ ▒▒▒▒▒▒▒▒ ▒▒▒▒▒▒▒▒ ▒▒ ▒▒ ▒▒▒▒▒▒▒▒ ▒▒▒▒ ▒▒ ▒▒▒▒ ▒▒▒▒▒ ▒▒▒▒▒ ▒▒▒▒ ▒▒ ▒▒▒▒ ▒
▓ ▓▓▓▓ ▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓ ▓▓ ▓▓▓▓ ▓ ▓ ▓▓ ▓▓▓▓ ▓▓▓ ▓▓▓▓ ▓▓▓▓▓ ▓▓▓▓▓ ▓▓▓▓ ▓▓ ▓▓
█ █████ ███████████ ████ ██ ████████ ██ ██ ████████ ███ ███ █████ █████ ████ ██ ███ ██
█ ████ ██ █████████ ███ ██ ███ ██ ██ ████ ██ ████ █████ ██████ ███ ████ █
"""
app = FastAPI(
title="AI Report Generator API App SMARTSHIELD",
)
# Add CORS middleware
app.add_middleware(
CORSMiddleware,
allow_origins=["*"], # Allows all origins, you can also specify a list of allowed origins
allow_credentials=True,
allow_methods=["*"], # Allows all HTTP methods (GET, POST, etc.)
allow_headers=["*"], # Allows all headers
)
logger.info(f"Starting App : \n {ascii_art}")
logger.info("App Ready")
app.include_router(router_generator.router)
@app.get("/", response_class=PlainTextResponse)
async def root():
return ascii_art
if __name__ == "__main__":
try :
uvicorn.run(
app,
port=8002,
host="0.0.0.0",
)
except KeyboardInterrupt as ki :
logger.info("Turning Server Off ...")
logger.info("server Off")
except Exception as e :
logger.critical(f"Critical Error occured in app : {e}")