Spaces:
Sleeping
Sleeping
Added db wake up endpoint
Browse files- main.py +0 -3
- routers/user.py +7 -1
main.py
CHANGED
|
@@ -28,6 +28,3 @@ app.include_router(holdings.router)
|
|
| 28 |
async def root():
|
| 29 |
return {"message": "Welcome to FinSight-AI"}
|
| 30 |
|
| 31 |
-
@app.get("/health")
|
| 32 |
-
async def health_check():
|
| 33 |
-
return {"status": "healthy"}
|
|
|
|
| 28 |
async def root():
|
| 29 |
return {"message": "Welcome to FinSight-AI"}
|
| 30 |
|
|
|
|
|
|
|
|
|
routers/user.py
CHANGED
|
@@ -1,6 +1,7 @@
|
|
| 1 |
from fastapi import APIRouter, Depends, HTTPException
|
| 2 |
from fastapi.security import OAuth2PasswordRequestForm
|
| 3 |
from sqlalchemy.orm import Session
|
|
|
|
| 4 |
from models import User
|
| 5 |
from database.connection import get_db
|
| 6 |
from auth.password import hash_password, verify_password
|
|
@@ -35,4 +36,9 @@ async def login_for_access_token(form_data: OAuth2PasswordRequestForm = Depends(
|
|
| 35 |
|
| 36 |
@router.get("/me", response_model=schemas.UserResponse)
|
| 37 |
async def get_logged_in_user(current_user: User = Depends(get_current_user)):
|
| 38 |
-
return current_user
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
from fastapi import APIRouter, Depends, HTTPException
|
| 2 |
from fastapi.security import OAuth2PasswordRequestForm
|
| 3 |
from sqlalchemy.orm import Session
|
| 4 |
+
from sqlalchemy import select, literal
|
| 5 |
from models import User
|
| 6 |
from database.connection import get_db
|
| 7 |
from auth.password import hash_password, verify_password
|
|
|
|
| 36 |
|
| 37 |
@router.get("/me", response_model=schemas.UserResponse)
|
| 38 |
async def get_logged_in_user(current_user: User = Depends(get_current_user)):
|
| 39 |
+
return current_user
|
| 40 |
+
|
| 41 |
+
@router.get("/health",)
|
| 42 |
+
async def health_check(db: Session = Depends(get_db)):
|
| 43 |
+
result = db.execute(select(literal(1))).scalar()
|
| 44 |
+
return {"status": "healthy"}
|