-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.py
More file actions
36 lines (26 loc) · 950 Bytes
/
Copy pathmain.py
File metadata and controls
36 lines (26 loc) · 950 Bytes
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
from contextlib import asynccontextmanager
import uvicorn
from fastapi import FastAPI
from database.database import engine
from database.base import Base
from sqlalchemy import text
from database.schemas import users
from routers.user_router import userRouter
from routers.ai_router import aiRouter
from sqlalchemy import text
Base.metadata.create_all(bind=engine)
with engine.connect() as conn:
conn.execute(text("""
ALTER TABLE users
ADD COLUMN IF NOT EXISTS guid VARCHAR
"""))
conn.commit()
app = FastAPI( debug=True, title="ExplainerAI API", description="API for ExplainerAI application", version="1.0.0" )
app.include_router(userRouter, prefix="/api/v1", tags=["Users"])
app.include_router(aiRouter, prefix="/api/v1", tags=["AI"])
@app.get("/")
def root():
return {"message": "FastAPI PostgreSQL Connected"}
if __name__ == "__main__":
import uvicorn
uvicorn.run(app, host="0.0.0.0", port=8000)