For now there are two methods: - `NETWORK:IsUrlAllowed()`: Check whether access to a certain URL is allowed. - `NETWORK:HttpRequest()`: Perform an HTTP request. By default access to the network is disabled for all target hosts. It can be enabled by setting `HttpEnable=1` in the preferences. Individual hosts have to be added to `HttpAllowHosts` as a comma separated list to allow access. See included docs for more details on usage.
29 lines
555 B
Python
29 lines
555 B
Python
#!/usr/bin/env python
|
|
|
|
import os
|
|
import asyncio
|
|
import websockets
|
|
|
|
connections = set()
|
|
|
|
async def echo(websocket, path):
|
|
|
|
connections.add(websocket)
|
|
|
|
try:
|
|
async for message in websocket:
|
|
print(message)
|
|
|
|
for ws in connections:
|
|
if ws != websocket:
|
|
await ws.send(message)
|
|
except:
|
|
raise
|
|
finally:
|
|
connections.remove(websocket)
|
|
|
|
|
|
asyncio.get_event_loop().run_until_complete(
|
|
websockets.serve(echo, 'localhost', 8080))
|
|
asyncio.get_event_loop().run_forever()
|