Spaces:
Sleeping
Sleeping
add frontend
Browse files
main.py
CHANGED
|
@@ -1,4 +1,6 @@
|
|
| 1 |
from fastapi import FastAPI, File, UploadFile, Form, HTTPException, Request, Depends
|
|
|
|
|
|
|
| 2 |
from fastapi.responses import JSONResponse
|
| 3 |
from fastapi.security import HTTPBearer, HTTPAuthorizationCredentials
|
| 4 |
from pydantic import BaseModel, HttpUrl
|
|
@@ -79,12 +81,14 @@ async def optimize_resume(
|
|
| 79 |
raise HTTPException(status_code=500, detail=f"An unexpected error occurred: {str(e)}")
|
| 80 |
|
| 81 |
# Mount the static directory
|
| 82 |
-
|
| 83 |
|
| 84 |
-
# Add a route
|
| 85 |
-
@app.get("/")
|
| 86 |
-
async def
|
| 87 |
-
|
|
|
|
|
|
|
| 88 |
|
| 89 |
@app.exception_handler(HTTPException)
|
| 90 |
async def http_exception_handler(request: Request, exc: HTTPException):
|
|
|
|
| 1 |
from fastapi import FastAPI, File, UploadFile, Form, HTTPException, Request, Depends
|
| 2 |
+
from fastapi.staticfiles import StaticFiles
|
| 3 |
+
from fastapi.responses import HTMLResponse
|
| 4 |
from fastapi.responses import JSONResponse
|
| 5 |
from fastapi.security import HTTPBearer, HTTPAuthorizationCredentials
|
| 6 |
from pydantic import BaseModel, HttpUrl
|
|
|
|
| 81 |
raise HTTPException(status_code=500, detail=f"An unexpected error occurred: {str(e)}")
|
| 82 |
|
| 83 |
# Mount the static directory
|
| 84 |
+
app.mount("/static", StaticFiles(directory="static"), name="static")
|
| 85 |
|
| 86 |
+
# Add a route for serving the HTML file
|
| 87 |
+
@app.get("/resume-optimizer", response_class=HTMLResponse)
|
| 88 |
+
async def serve_resume_optimizer():
|
| 89 |
+
with open("static/resume-optimizer.html", "r") as file:
|
| 90 |
+
content = file.read()
|
| 91 |
+
return HTMLResponse(content=content)
|
| 92 |
|
| 93 |
@app.exception_handler(HTTPException)
|
| 94 |
async def http_exception_handler(request: Request, exc: HTTPException):
|