Web Sockets Working

This commit is contained in:
2026-05-02 19:26:17 -04:00
parent f34125d67b
commit 24fed2fa7a
5 changed files with 11 additions and 4 deletions

Binary file not shown.

View File

@@ -8,6 +8,8 @@ from problem_generator import generate_problem
from steps_generator import generate_steps
from sympy import init_printing, sympify
from fastapi import FastAPI, WebSocket, WebSocketDisconnect
from fastapi.staticfiles import StaticFiles
from fastapi.responses import RedirectResponse
logging.basicConfig(
level=logging.INFO,
@@ -19,11 +21,14 @@ logging.basicConfig(
)
log = logging.getLogger(__name__)
app = FastAPI()
clients = []
app.mount("/static", StaticFiles(directory="www"), name="static")
@app.get("/static")
def static_root():
return RedirectResponse(url="/static/index.html")
@app.websocket("/ws")
async def websocket_endpoint(ws: WebSocket):
await ws.accept()

View File

@@ -1,3 +1,4 @@
sympy
fastapi
uvicorn
uvicorn
uvicorn[standard]

View File

@@ -1,4 +1,5 @@
const socket = new WebSocket("ws://localhost:8000/ws");
//const socket = new WebSocket("ws://localhost:8000/ws");
const socket = new WebSocket("ws://10.0.0.50:8000/ws");
let problemData = null;
let stepIndex = 0;