Spaces:
Sleeping
Sleeping
Create app.py
Browse files
app.py
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from fastapi import FastAPI, Request, Form
|
| 2 |
+
from fastapi.responses import HTMLResponse
|
| 3 |
+
from fastapi.templating import Jinja2Templates
|
| 4 |
+
from career_data import get_career_recommendations
|
| 5 |
+
|
| 6 |
+
app = FastAPI()
|
| 7 |
+
|
| 8 |
+
# Load templates from the templates directory
|
| 9 |
+
templates = Jinja2Templates(directory="templates")
|
| 10 |
+
|
| 11 |
+
@app.get("/", response_class=HTMLResponse)
|
| 12 |
+
async def read_root(request: Request):
|
| 13 |
+
return templates.TemplateResponse("index.html", {"request": request})
|
| 14 |
+
|
| 15 |
+
@app.post("/recommend", response_class=HTMLResponse)
|
| 16 |
+
async def recommend_career(request: Request, skills: str = Form(...), interests: str = Form(...)):
|
| 17 |
+
recommendations = get_career_recommendations(skills, interests)
|
| 18 |
+
return templates.TemplateResponse("index.html", {
|
| 19 |
+
"request": request,
|
| 20 |
+
"recommendations": recommendations,
|
| 21 |
+
"skills": skills,
|
| 22 |
+
"interests": interests
|
| 23 |
+
})
|
| 24 |
+
|