-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrun_api.py
More file actions
44 lines (35 loc) · 1 KB
/
run_api.py
File metadata and controls
44 lines (35 loc) · 1 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
import uvicorn
from fastapi import FastAPI
from fastapi.middleware.cors import CORSMiddleware
from src.api.routes import api_router
from src.api.middleware import log_requests
from config.settings import Settings
def create_app():
app = FastAPI(
title="CodeIntelliGen API",
description="AI-Powered Code Generation and Bug Detection System",
version="1.0.0",
docs_url="/docs",
redoc_url="/redoc"
)
app.add_middleware(
CORSMiddleware,
allow_origins=["*"],
allow_credentials=True,
allow_methods=["*"],
allow_headers=["*"],
)
app.middleware("http")(log_requests)
app.include_router(api_router, prefix="/api/v1")
return app
def main():
settings = Settings()
app = create_app()
uvicorn.run(
app,
host=settings.API_HOST,
port=settings.API_PORT,
debug=settings.DEBUG
)
if __name__ == "__main__":
main()