You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
23 lines
523 B
Python
23 lines
523 B
Python
from starlette.applications import Starlette
|
|
from starlette.responses import JSONResponse
|
|
import uvicorn
|
|
|
|
app = Starlette(debug=True)
|
|
|
|
|
|
@app.route('/')
|
|
async def index(request):
|
|
return JSONResponse({"Hello": "Dirp"})
|
|
|
|
|
|
@app.websocket_route('/ws')
|
|
async def websocket_endpoint(websocket):
|
|
await websocket.accept()
|
|
while True:
|
|
data = await websocket.receive_text()
|
|
await websocket.send_text(f"Message text was: {data}")
|
|
|
|
|
|
if __name__ == "__main__":
|
|
uvicorn.run(app, host="0.0.0.0", port=8010)
|