from fastapi import FastAPI, Request, Form from fastapi.responses import HTMLResponse from fastapi.templating import Jinja2Templates from career_data import get_career_recommendations app = FastAPI() # Load templates from the templates directory templates = Jinja2Templates(directory="templates") @app.get("/", response_class=HTMLResponse) async def read_root(request: Request): return templates.TemplateResponse("index.html", {"request": request}) @app.post("/recommend", response_class=HTMLResponse) async def recommend_career(request: Request, skills: str = Form(...), interests: str = Form(...)): recommendations = get_career_recommendations(skills, interests) return templates.TemplateResponse("index.html", { "request": request, "recommendations": recommendations, "skills": skills, "interests": interests })