Spaces:
Sleeping
Sleeping
Ajit Panday
commited on
Commit
·
093b53f
1
Parent(s):
fba5cdd
Fix customer list endpoint
Browse files- app/auth.py +9 -2
app/auth.py
CHANGED
|
@@ -151,8 +151,15 @@ async def list_customers(
|
|
| 151 |
current_admin: str = Depends(get_current_admin)
|
| 152 |
):
|
| 153 |
"""List all customers"""
|
| 154 |
-
|
| 155 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 156 |
|
| 157 |
@router.get("/customers/{customer_id}", response_model=dict)
|
| 158 |
async def get_customer(
|
|
|
|
| 151 |
current_admin: str = Depends(get_current_admin)
|
| 152 |
):
|
| 153 |
"""List all customers"""
|
| 154 |
+
try:
|
| 155 |
+
customers = db.query(Customer).all()
|
| 156 |
+
return customers
|
| 157 |
+
except Exception as e:
|
| 158 |
+
print(f"Error listing customers: {str(e)}")
|
| 159 |
+
raise HTTPException(
|
| 160 |
+
status_code=status.HTTP_500_INTERNAL_SERVER_ERROR,
|
| 161 |
+
detail=f"Error listing customers: {str(e)}"
|
| 162 |
+
)
|
| 163 |
|
| 164 |
@router.get("/customers/{customer_id}", response_model=dict)
|
| 165 |
async def get_customer(
|