Update app.py
Browse files
app.py
CHANGED
|
@@ -4,7 +4,7 @@ import json
|
|
| 4 |
import pty
|
| 5 |
from fastapi import FastAPI, WebSocket, WebSocketDisconnect, Query
|
| 6 |
from fastapi.middleware.cors import CORSMiddleware
|
| 7 |
-
from starlette.websockets import WebSocketCloseReason
|
| 8 |
|
| 9 |
app = FastAPI()
|
| 10 |
|
|
@@ -20,7 +20,7 @@ app.add_middleware(
|
|
| 20 |
@app.websocket("/ws")
|
| 21 |
async def websocket_endpoint(websocket: WebSocket, password: str = Query(default="")):
|
| 22 |
if password != PASSWORD:
|
| 23 |
-
await websocket.close(code=
|
| 24 |
print("Conexão recusada: senha incorreta")
|
| 25 |
return
|
| 26 |
|
|
|
|
| 4 |
import pty
|
| 5 |
from fastapi import FastAPI, WebSocket, WebSocketDisconnect, Query
|
| 6 |
from fastapi.middleware.cors import CORSMiddleware
|
| 7 |
+
# from starlette.websockets import WebSocketCloseReason
|
| 8 |
|
| 9 |
app = FastAPI()
|
| 10 |
|
|
|
|
| 20 |
@app.websocket("/ws")
|
| 21 |
async def websocket_endpoint(websocket: WebSocket, password: str = Query(default="")):
|
| 22 |
if password != PASSWORD:
|
| 23 |
+
await websocket.close(code=1008)
|
| 24 |
print("Conexão recusada: senha incorreta")
|
| 25 |
return
|
| 26 |
|