Skip to content

Commit fe23bdf

Browse files
author
Paul Sokolovsky
committed
asyncio_micro: Add basic HTTP server example.
1 parent 1d9f785 commit fe23bdf

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

asyncio_micro/test_http_server.py

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
import asyncio_micro as asyncio
2+
3+
@asyncio.coroutine
4+
def serve(reader, writer):
5+
print(reader, writer)
6+
print("================")
7+
print((yield from reader.read()))
8+
yield from writer.write("HTTP/1.0 200 OK\r\n\r\nHello.\r\n")
9+
print("After response write")
10+
yield from writer.close()
11+
print("Finished processing request")
12+
13+
14+
import logging
15+
#logging.basicConfig(level=logging.INFO)
16+
logging.basicConfig(level=logging.DEBUG)
17+
loop = asyncio.get_event_loop()
18+
mem_info()
19+
loop.call_soon(asyncio.start_server(serve, "127.0.0.1", 8081))
20+
loop.run_forever()
21+
loop.close()

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy