Spaces:
Building
Building
Update admin_routes.py
Browse files- admin_routes.py +25 -0
admin_routes.py
CHANGED
@@ -381,6 +381,31 @@ async def list_projects(
|
|
381 |
|
382 |
return projects
|
383 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
384 |
@router.post("/projects")
|
385 |
async def create_project(project_data: dict, current_user: str = Depends(auth.get_current_user)):
|
386 |
"""Create new project"""
|
|
|
381 |
|
382 |
return projects
|
383 |
|
384 |
+
@router.get("/projects/{project_id}")
|
385 |
+
async def get_project(project_id: int, current_user: str = Depends(auth.get_current_user)):
|
386 |
+
"""Get single project by ID"""
|
387 |
+
try:
|
388 |
+
config = load_config()
|
389 |
+
projects = config.get("projects", [])
|
390 |
+
|
391 |
+
# Find project
|
392 |
+
project = next((p for p in projects if p.get("id") == project_id), None)
|
393 |
+
|
394 |
+
if not project:
|
395 |
+
raise HTTPException(status_code=404, detail="Project not found")
|
396 |
+
|
397 |
+
# Filter deleted if not requested
|
398 |
+
if project.get("deleted", False):
|
399 |
+
raise HTTPException(status_code=404, detail="Project not found")
|
400 |
+
|
401 |
+
return project
|
402 |
+
|
403 |
+
except HTTPException:
|
404 |
+
raise
|
405 |
+
except Exception as e:
|
406 |
+
logger.error(f"Failed to get project: {str(e)}")
|
407 |
+
raise HTTPException(status_code=500, detail=str(e))
|
408 |
+
|
409 |
@router.post("/projects")
|
410 |
async def create_project(project_data: dict, current_user: str = Depends(auth.get_current_user)):
|
411 |
"""Create new project"""
|