File size: 869 Bytes
4726a3b
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
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
    })