Add the start of a Python server implementation.
I'm on a plane, I can't be looking up golang stuff.
This commit is contained in:
parent
39ff9c3a8e
commit
e227d349b2
|
@ -0,0 +1,22 @@
|
|||
import asyncio
|
||||
import asyncio.streams
|
||||
import logging
|
||||
|
||||
LOGGER = logging.getLogger("server")
|
||||
|
||||
def main():
|
||||
logging.basicConfig(level=logging.DEBUG)
|
||||
asyncio.run(run())
|
||||
|
||||
async def on_connect(reader, writer):
|
||||
LOGGER.info("connected")
|
||||
data = await reader.read()
|
||||
print(data.decode("UTF-8"))
|
||||
|
||||
async def run():
|
||||
server = await asyncio.start_server(on_connect, host="localhost", port=9988)
|
||||
async with server:
|
||||
await server.serve_forever()
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
Loading…
Reference in New Issue