akborana4 commited on
Commit
3a6d00d
·
verified ·
1 Parent(s): 01ba227

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +4 -1
app.py CHANGED
@@ -38,6 +38,10 @@ fastapi_app.mount("/uploads", StaticFiles(directory=UPLOAD_DIR), name="uploads")
38
  # Serve static assets in /public
39
  fastapi_app.mount("/static", StaticFiles(directory="public"), name="public")
40
 
 
 
 
 
41
  @fastapi_app.get("/", response_class=HTMLResponse)
42
  async def root():
43
  return FileResponse("public/index.html")
@@ -127,7 +131,6 @@ async def upload_file(file: UploadFile = File(...)):
127
  # ------------------------
128
  # Socket.IO events
129
  # ------------------------
130
- asgi = socketio.ASGIApp(sio, other_asgi_app=fastapi_app)
131
 
132
  @sio.event
133
  async def connect(sid, environ):
 
38
  # Serve static assets in /public
39
  fastapi_app.mount("/static", StaticFiles(directory="public"), name="public")
40
 
41
+ # This is the corrected way to integrate Socket.IO and FastAPI.
42
+ # It ensures all requests, including Socket.IO's, are handled correctly.
43
+ asgi = socketio.ASGIApp(sio, other_asgi_app=fastapi_app)
44
+
45
  @fastapi_app.get("/", response_class=HTMLResponse)
46
  async def root():
47
  return FileResponse("public/index.html")
 
131
  # ------------------------
132
  # Socket.IO events
133
  # ------------------------
 
134
 
135
  @sio.event
136
  async def connect(sid, environ):