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:
Eli Ribble 2023-06-19 18:03:21 -07:00
parent 39ff9c3a8e
commit e227d349b2
1 changed files with 22 additions and 0 deletions

22
server.py Normal file
View File

@ -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()