diff options
author | Paul Sokolovsky <pfalcon@users.sourceforge.net> | 2016-04-02 20:53:29 +0300 |
---|---|---|
committer | Paul Sokolovsky <pfalcon@users.sourceforge.net> | 2016-04-02 20:53:29 +0300 |
commit | aa3fb7b3876d868b0070ca85d97f700e0c2dec20 (patch) | |
tree | 944da1ac28e03960a4730265232baaa52606be47 /examples/network/http_server.py | |
parent | fd2b71f972d29496768892467c7b2024af25f157 (diff) | |
download | micropython-aa3fb7b3876d868b0070ca85d97f700e0c2dec20.tar.gz micropython-aa3fb7b3876d868b0070ca85d97f700e0c2dec20.zip |
examples/http_server.py: Refactor/simplify for Python 3.5.
Diffstat (limited to 'examples/network/http_server.py')
-rw-r--r-- | examples/network/http_server.py | 13 |
1 files changed, 7 insertions, 6 deletions
diff --git a/examples/network/http_server.py b/examples/network/http_server.py index 7affafcfd6..923b4f9aef 100644 --- a/examples/network/http_server.py +++ b/examples/network/http_server.py @@ -4,10 +4,10 @@ except: import socket -CONTENT = """\ +CONTENT = b"""\ HTTP/1.0 200 OK -Hello #{} from MicroPython! +Hello #%d from MicroPython! """ s = socket.socket() @@ -30,12 +30,13 @@ while True: print("Client socket:", client_s) print("Request:") if 0: - # MicroPython rawsocket module supports file interface directly + # MicroPython socket objects support stream (aka file) interface + # directly. print(client_s.read(4096)) - #print(client_s.readall()) - client_s.write(CONTENT.format(counter)) + client_s.write(CONTENT % counter) else: print(client_s.recv(4096)) - client_s.send(bytes(CONTENT.format(counter), "ascii")) + client_s.send(CONTENT % counter) client_s.close() counter += 1 + print() |