Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
[Asyncio built-in Socket Server] #python #python3 #asyncio #server #socket #web #http
import asyncio
async def handle_request(reader, writer):
writer.write("hello world".encode()) # needs to be bytes not string
writer.close()
async def main():
srv = await asyncio.start_server(handle_request, '127.0.0.1', 8081)
async with srv:
await srv.serve_forever()
asyncio.run(main())
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.