Spaces:
Runtime error
Runtime error
test
Browse files- Dockerfile +2 -2
- app/main.py +13 -1
Dockerfile
CHANGED
@@ -6,12 +6,12 @@ COPY ./requirements.txt /code/requirements.txt
|
|
6 |
|
7 |
COPY ./app /code/app
|
8 |
|
9 |
-
RUN pip install --no-cache-dir --upgrade -r /code/requirements.txt
|
10 |
-
|
11 |
RUN useradd -m docker && echo "docker:docker" | chpasswd && adduser docker sudo
|
12 |
|
13 |
USER docker
|
14 |
|
|
|
|
|
15 |
EXPOSE 7860
|
16 |
|
17 |
CMD ["fastapi", "run", "/code/app/main.py", "--port", "7860"]
|
|
|
6 |
|
7 |
COPY ./app /code/app
|
8 |
|
|
|
|
|
9 |
RUN useradd -m docker && echo "docker:docker" | chpasswd && adduser docker sudo
|
10 |
|
11 |
USER docker
|
12 |
|
13 |
+
RUN pip install --no-cache-dir --upgrade -r /code/requirements.txt
|
14 |
+
|
15 |
EXPOSE 7860
|
16 |
|
17 |
CMD ["fastapi", "run", "/code/app/main.py", "--port", "7860"]
|
app/main.py
CHANGED
@@ -43,20 +43,32 @@ manager = ConnectionManager()
|
|
43 |
|
44 |
@app.websocket("/ws/{client_id}")
|
45 |
async def websocket_endpoint(websocket: WebSocket, client_id: int):
|
|
|
46 |
await manager.connect(websocket)
|
|
|
47 |
now = datetime.now()
|
48 |
current_time = now.strftime("%H:%M")
|
|
|
49 |
try:
|
50 |
while True:
|
|
|
51 |
data = await websocket.receive_text()
|
52 |
-
|
|
|
|
|
53 |
message = {"time":current_time,"clientId":client_id,"message":data}
|
|
|
54 |
await manager.broadcast(json.dumps(message))
|
|
|
55 |
|
56 |
except WebSocketDisconnect:
|
|
|
57 |
manager.disconnect(websocket)
|
|
|
58 |
message = {"time":current_time,"clientId":client_id,"message":"Offline"}
|
|
|
59 |
await manager.broadcast(json.dumps(message))
|
|
|
60 |
|
61 |
@app.get("/query")
|
62 |
async def process_input(text: str):
|
|
|
43 |
|
44 |
@app.websocket("/ws/{client_id}")
|
45 |
async def websocket_endpoint(websocket: WebSocket, client_id: int):
|
46 |
+
print("CONNECTING")
|
47 |
await manager.connect(websocket)
|
48 |
+
print("1")
|
49 |
now = datetime.now()
|
50 |
current_time = now.strftime("%H:%M")
|
51 |
+
print("2")
|
52 |
try:
|
53 |
while True:
|
54 |
+
print("3")
|
55 |
data = await websocket.receive_text()
|
56 |
+
print("4")
|
57 |
+
await manager.send_personal_message(f"You wrote: {data}", websocket)
|
58 |
+
print("5")
|
59 |
message = {"time":current_time,"clientId":client_id,"message":data}
|
60 |
+
print("6")
|
61 |
await manager.broadcast(json.dumps(message))
|
62 |
+
print("7")
|
63 |
|
64 |
except WebSocketDisconnect:
|
65 |
+
print("DISCONNECTING")
|
66 |
manager.disconnect(websocket)
|
67 |
+
print("1")
|
68 |
message = {"time":current_time,"clientId":client_id,"message":"Offline"}
|
69 |
+
print("2")
|
70 |
await manager.broadcast(json.dumps(message))
|
71 |
+
print("3")
|
72 |
|
73 |
@app.get("/query")
|
74 |
async def process_input(text: str):
|