Spaces:
Sleeping
Sleeping
Update main.py
Browse files
main.py
CHANGED
@@ -1,43 +1,39 @@
|
|
1 |
-
from fastapi import FastAPI, Form, Request
|
2 |
-
from fastapi.responses import JSONResponse, FileResponse
|
3 |
-
from fastapi.staticfiles import StaticFiles
|
4 |
-
from starlette.middleware.sessions import SessionMiddleware
|
5 |
-
from groq_client import generate_questions, evaluate_answers
|
6 |
-
import json
|
7 |
-
import uvicorn
|
8 |
-
|
9 |
-
app = FastAPI()
|
10 |
-
|
11 |
-
# Serve static files (HTML, CSS, JS)
|
12 |
-
app.mount("/static", StaticFiles(directory="static"), name="static")
|
13 |
-
|
14 |
-
# Add session middleware
|
15 |
-
app.add_middleware(SessionMiddleware, secret_key="vhjh64@$t4#$%yhgxt45ljo##")
|
16 |
-
|
17 |
-
|
18 |
-
@app.get("/", response_class=FileResponse)
|
19 |
-
async def index():
|
20 |
-
return FileResponse("static/index.html")
|
21 |
-
|
22 |
-
|
23 |
-
@app.post("/start", response_class=JSONResponse)
|
24 |
-
async def start(career: str = Form(...), qualifications: str = Form(...)):
|
25 |
-
# Mock question generation
|
26 |
-
questions_str = await generate_questions(career, qualifications)
|
27 |
-
questions_data = json.loads(questions_str)
|
28 |
-
return {"questions": questions_data["questions"]}
|
29 |
-
|
30 |
-
|
31 |
-
@app.post("/evaluate", response_class=JSONResponse)
|
32 |
-
async def evaluate(payload: dict):
|
33 |
-
# Mock evaluation logic
|
34 |
-
career = payload.get("career")
|
35 |
-
qualifications = payload.get("qualifications")
|
36 |
-
answers = payload.get("answers")
|
37 |
-
result = await evaluate_answers(career, qualifications, answers)
|
38 |
-
result_data=json.loads(result)
|
39 |
-
return {"result": result_data}
|
40 |
-
|
41 |
-
|
42 |
-
if __name__ == "__main__":
|
43 |
-
uvicorn.run("main:app", host="0.0.0.0", port=8000, reload=True)
|
|
|
1 |
+
from fastapi import FastAPI, Form, Request
|
2 |
+
from fastapi.responses import JSONResponse, FileResponse
|
3 |
+
from fastapi.staticfiles import StaticFiles
|
4 |
+
from starlette.middleware.sessions import SessionMiddleware
|
5 |
+
from groq_client import generate_questions, evaluate_answers
|
6 |
+
import json
|
7 |
+
import uvicorn
|
8 |
+
|
9 |
+
app = FastAPI()
|
10 |
+
|
11 |
+
# Serve static files (HTML, CSS, JS)
|
12 |
+
app.mount("/static", StaticFiles(directory="static"), name="static")
|
13 |
+
|
14 |
+
# Add session middleware
|
15 |
+
app.add_middleware(SessionMiddleware, secret_key="vhjh64@$t4#$%yhgxt45ljo##")
|
16 |
+
|
17 |
+
|
18 |
+
@app.get("/", response_class=FileResponse)
|
19 |
+
async def index():
|
20 |
+
return FileResponse("static/index.html")
|
21 |
+
|
22 |
+
|
23 |
+
@app.post("/start", response_class=JSONResponse)
|
24 |
+
async def start(career: str = Form(...), qualifications: str = Form(...)):
|
25 |
+
# Mock question generation
|
26 |
+
questions_str = await generate_questions(career, qualifications)
|
27 |
+
questions_data = json.loads(questions_str)
|
28 |
+
return {"questions": questions_data["questions"]}
|
29 |
+
|
30 |
+
|
31 |
+
@app.post("/evaluate", response_class=JSONResponse)
|
32 |
+
async def evaluate(payload: dict):
|
33 |
+
# Mock evaluation logic
|
34 |
+
career = payload.get("career")
|
35 |
+
qualifications = payload.get("qualifications")
|
36 |
+
answers = payload.get("answers")
|
37 |
+
result = await evaluate_answers(career, qualifications, answers)
|
38 |
+
result_data=json.loads(result)
|
39 |
+
return {"result": result_data}
|
|
|
|
|
|
|
|