CoolFace
Apppublic

Coder19/interview_system

sourceHugging Faceupdated 1y agoView on Hugging Face
0likes
question_test.py33 linesDownload Raw Back to api
1from fastapi import APIRouter, HTTPException2from pydantic import BaseModel3from interview_prep.question import generate_mcqs, generate_coding_questions4 5router = APIRouter()6 7class DomainRequest(BaseModel):8    domain: str9 10@router.post("/generate-questions")11def generate_test(request: DomainRequest):12    """Generate MCQs and coding questions for the given domain."""13    domain = request.domain.strip()14    15    if not domain:16        raise HTTPException(status_code=400, detail="Domain cannot be empty")17 18    # Generate MCQs19    mcq_questions = generate_mcqs(domain)20 21    # Generate coding questions22    coding_questions = generate_coding_questions()23 24    # Standardize coding questions response25    if isinstance(coding_questions, str):26        coding_questions = {"error": coding_questions}27 28    return {29        "domain": domain,30        "MCQ": mcq_questions,31        "Coding Questions": coding_questions32    }33