pvanand commited on
Commit
90ca14a
·
verified ·
1 Parent(s): 3279633

add frontend

Browse files
Files changed (1) hide show
  1. main.py +9 -5
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
- # app.mount("/static", StaticFiles(directory="static"), name="static")
83
 
84
- # Add a route to serve the HTML file
85
- @app.get("/")
86
- async def read_index():
87
- return FileResponse('static/resume-optimizer.html')
 
 
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):