Ashrafb commited on
Commit
30bb977
1 Parent(s): b3066fe

Update main.py

Browse files
Files changed (1) hide show
  1. main.py +10 -5
main.py CHANGED
@@ -44,6 +44,16 @@ def respond(message, history: list[tuple[str, str]]):
44
  for message in response: # Handle regular iteration
45
  yield message.choices[0].delta.content
46
 
 
 
 
 
 
 
 
 
 
 
47
  @app.post("/generate/")
48
  async def generate(request: Request):
49
  form = await request.form()
@@ -60,8 +70,3 @@ async def generate(request: Request):
60
 
61
  return JSONResponse(content={"response": final_response})
62
 
63
- app.mount("/", StaticFiles(directory="static", html=True), name="static")
64
-
65
- @app.get("/")
66
- def index() -> FileResponse:
67
- return FileResponse(path="/app/static/index.html", media_type="text/html")
 
44
  for message in response: # Handle regular iteration
45
  yield message.choices[0].delta.content
46
 
47
+ from fastapi.middleware.cors import CORSMiddleware
48
+
49
+ app.add_middleware(
50
+ CORSMiddleware,
51
+ allow_origins=["https://huggingface.co/spaces/Artixiban/Ll3"], # Adjust as needed, '*' allows requests from any origin
52
+ allow_credentials=True,
53
+ allow_methods=["*"],
54
+ allow_headers=["*"],
55
+ )
56
+
57
  @app.post("/generate/")
58
  async def generate(request: Request):
59
  form = await request.form()
 
70
 
71
  return JSONResponse(content={"response": final_response})
72