Files
canopy-workloads/learning/app/routes.py
T
kiskaadee 19a63811e2 refactor(learning): purge unnecessary system stats and docker integration
This commit removes the system monitoring, docker status, and bookmark
features from the learning board to reduce complexity and improve
security

- Remove `/system-stats`, and `/bookmarks` API endpoints and their
  controller logic
- Drop Python dependencies `psutils` and `docker` (and associated
  lockfile entries)
- Remove Docker socket proxy configuration, network bindings, and
  environment variables from `docker-compose.yml` and `config.py`
- Remove the read-only `/home` volume mount from the Docker compose file
2026-07-09 15:20:06 -05:00

30 lines
1.3 KiB
Python

from fastapi import APIRouter, Depends, HTTPException
from sqlalchemy.orm import Session
from typing import List, Dict, Any
from . import models, controllers, database
router = APIRouter(prefix="/api")
@router.get("/courses", response_model=List[models.Course])
def read_courses(db: Session = Depends(database.get_db)) -> List[models.ORMCourse]:
return controllers.get_courses(db)
@router.post("/courses", response_model=models.Course)
def create_course(course: models.CourseCreate, db: Session = Depends(database.get_db)) -> models.ORMCourse:
return controllers.create_course(db, course)
@router.put("/courses/{course_id}", response_model=models.Course)
def update_course(course_id: int, course: models.CourseCreate, db: Session = Depends(database.get_db)) -> models.ORMCourse:
db_course = controllers.update_course(db, course_id, course)
if not db_course:
raise HTTPException(status_code=404, detail="Course not found")
return db_course
@router.delete("/courses/{course_id}")
def delete_course(course_id: int, db: Session = Depends(database.get_db)) -> Dict[str, str]:
success = controllers.delete_course(db, course_id)
if not success:
raise HTTPException(status_code=404, detail="Course not found")
return {"message": "Course deleted"}