feat: testing new endpoint
Browse files
Backend/.gitignore → .gitignore
RENAMED
|
@@ -216,3 +216,4 @@ __marimo__/
|
|
| 216 |
.streamlit/secrets.toml
|
| 217 |
|
| 218 |
playground/psql_driver.ipynb
|
|
|
|
|
|
| 216 |
.streamlit/secrets.toml
|
| 217 |
|
| 218 |
playground/psql_driver.ipynb
|
| 219 |
+
Backend/Time complexity cheatsheet.pdf
|
Backend/.pre-commit-config.yaml → .pre-commit-config.yaml
RENAMED
|
File without changes
|
Backend/app/api/v1/api.py
CHANGED
|
@@ -1,5 +1,5 @@
|
|
| 1 |
from fastapi import APIRouter
|
| 2 |
-
from app.api.v1.endpoints import auth, students
|
| 3 |
|
| 4 |
api_router = APIRouter()
|
| 5 |
|
|
@@ -16,3 +16,10 @@ api_router.include_router(
|
|
| 16 |
prefix="/students",
|
| 17 |
tags=["Students"]
|
| 18 |
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
from fastapi import APIRouter
|
| 2 |
+
from app.api.v1.endpoints import auth, students, quiz
|
| 3 |
|
| 4 |
api_router = APIRouter()
|
| 5 |
|
|
|
|
| 16 |
prefix="/students",
|
| 17 |
tags=["Students"]
|
| 18 |
)
|
| 19 |
+
|
| 20 |
+
# Include student routes
|
| 21 |
+
api_router.include_router(
|
| 22 |
+
quiz.router,
|
| 23 |
+
prefix="/quiz",
|
| 24 |
+
tags=["quiz"]
|
| 25 |
+
)
|
Backend/app/api/v1/endpoints/quiz.py
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from fastapi import APIRouter, HTTPException, Depends, status
|
| 2 |
+
from sqlalchemy.ext.asyncio import AsyncSession
|
| 3 |
+
from sqlalchemy import select
|
| 4 |
+
from typing import List
|
| 5 |
+
from app.schema import StudentCreate, StudentUpdate, StudentResponse
|
| 6 |
+
from app.models import Student, User
|
| 7 |
+
from app.api.deps import get_db, get_current_user
|
| 8 |
+
|
| 9 |
+
router = APIRouter()
|
| 10 |
+
|
| 11 |
+
@router.get("/", response_model=List[StudentResponse])
|
| 12 |
+
async def get_all_students(
|
| 13 |
+
skip: int = 0,
|
| 14 |
+
limit: int = 100,
|
| 15 |
+
db: AsyncSession = Depends(get_db),
|
| 16 |
+
current_user: User = Depends(get_current_user)
|
| 17 |
+
):
|
| 18 |
+
"""Get all students with pagination (Protected)"""
|
| 19 |
+
try:
|
| 20 |
+
result = await db.execute(
|
| 21 |
+
select(Student).offset(skip).limit(limit)
|
| 22 |
+
)
|
| 23 |
+
students = result.scalars().all()
|
| 24 |
+
return students
|
| 25 |
+
except Exception as e:
|
| 26 |
+
raise HTTPException(
|
| 27 |
+
status_code=status.HTTP_500_INTERNAL_SERVER_ERROR,
|
| 28 |
+
detail=f"Failed to fetch students: {str(e)}"
|
| 29 |
+
)
|
Backend/Readme.md → Readme.md
RENAMED
|
File without changes
|