We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent fd2b71f commit aa3fb7bCopy full SHA for aa3fb7b
1 file changed
examples/network/http_server.py
@@ -4,10 +4,10 @@
4
import socket
5
6
7
-CONTENT = """\
+CONTENT = b"""\
8
HTTP/1.0 200 OK
9
10
-Hello #{} from MicroPython!
+Hello #%d from MicroPython!
11
"""
12
13
s = socket.socket()
@@ -30,12 +30,13 @@
30
print("Client socket:", client_s)
31
print("Request:")
32
if 0:
33
- # MicroPython rawsocket module supports file interface directly
+ # MicroPython socket objects support stream (aka file) interface
34
+ # directly.
35
print(client_s.read(4096))
- #print(client_s.readall())
36
- client_s.write(CONTENT.format(counter))
+ client_s.write(CONTENT % counter)
37
else:
38
print(client_s.recv(4096))
39
- client_s.send(bytes(CONTENT.format(counter), "ascii"))
+ client_s.send(CONTENT % counter)
40
client_s.close()
41
counter += 1
42
+ print()
0 commit comments