23 lines
471 B
Python
23 lines
471 B
Python
|
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()
|