Web Sockets Working
This commit is contained in:
Binary file not shown.
9
main.py
9
main.py
@@ -8,6 +8,8 @@ from problem_generator import generate_problem
|
|||||||
from steps_generator import generate_steps
|
from steps_generator import generate_steps
|
||||||
from sympy import init_printing, sympify
|
from sympy import init_printing, sympify
|
||||||
from fastapi import FastAPI, WebSocket, WebSocketDisconnect
|
from fastapi import FastAPI, WebSocket, WebSocketDisconnect
|
||||||
|
from fastapi.staticfiles import StaticFiles
|
||||||
|
from fastapi.responses import RedirectResponse
|
||||||
|
|
||||||
logging.basicConfig(
|
logging.basicConfig(
|
||||||
level=logging.INFO,
|
level=logging.INFO,
|
||||||
@@ -19,11 +21,14 @@ logging.basicConfig(
|
|||||||
)
|
)
|
||||||
|
|
||||||
log = logging.getLogger(__name__)
|
log = logging.getLogger(__name__)
|
||||||
|
|
||||||
app = FastAPI()
|
app = FastAPI()
|
||||||
|
|
||||||
clients = []
|
clients = []
|
||||||
|
|
||||||
|
app.mount("/static", StaticFiles(directory="www"), name="static")
|
||||||
|
@app.get("/static")
|
||||||
|
def static_root():
|
||||||
|
return RedirectResponse(url="/static/index.html")
|
||||||
|
|
||||||
@app.websocket("/ws")
|
@app.websocket("/ws")
|
||||||
async def websocket_endpoint(ws: WebSocket):
|
async def websocket_endpoint(ws: WebSocket):
|
||||||
await ws.accept()
|
await ws.accept()
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
sympy
|
sympy
|
||||||
fastapi
|
fastapi
|
||||||
uvicorn
|
uvicorn
|
||||||
|
uvicorn[standard]
|
||||||
@@ -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 problemData = null;
|
||||||
let stepIndex = 0;
|
let stepIndex = 0;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user