Skip to content

Instantly share code, notes, and snippets.

@tamert
Created October 17, 2022 20:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tamert/6b1807e6e2faa4456d814efc122fbb76 to your computer and use it in GitHub Desktop.
Save tamert/6b1807e6e2faa4456d814efc122fbb76 to your computer and use it in GitHub Desktop.
import asyncio
async def hello(reader, writer):
data = await reader.read(100)
writer.write(b'hello world!')
await writer.drain()
writer.close()
async def main():
server = await asyncio.start_server(hello, '127.0.0.1', 80)
async with server:
await server.serve_forever()
asyncio.run(main())
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment