diff --git a/endpoints/api/v1/endpoint.post.py b/endpoints/api/v1/endpoint.post.py new file mode 100644 index 0000000..cc35947 --- /dev/null +++ b/endpoints/api/v1/endpoint.post.py @@ -0,0 +1,50 @@ +from fastapi import APIRouter, Depends, HTTPException +from core.database import fake_users_db +import uuid +from typing import List, Optional + +router = APIRouter() + +@router.post("/courses") +async def create_course( + title: str, + description: str, + instructor_id: str, + price: float, + duration_weeks: int, + max_students: Optional[int] = None +): + """Create a new course in the online school""" + course_id = str(uuid.uuid4()) + + if not fake_users_db.get(instructor_id): + raise HTTPException(status_code=400, detail="Instructor not found") + + course = { + "id": course_id, + "title": title, + "description": description, + "instructor_id": instructor_id, + "price": price, + "duration_weeks": duration_weeks, + "max_students": max_students, + "enrolled_students": [], + "status": "active" + } + + fake_users_db[course_id] = course + + return { + "message": "Course created successfully", + "course_id": course_id, + "course_details": course, + "features": { + "enrollment_open": True, + "materials_ready": False + }, + "next_steps": [ + "Upload course materials", + "Set up course schedule", + "Invite students" + ] + } \ No newline at end of file