Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
M
micropython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Analytics
Analytics
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Commits
Open sidebar
xpstem
micropython
Commits
aa3fb7b3
Commit
aa3fb7b3
authored
Apr 02, 2016
by
Paul Sokolovsky
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
examples/http_server.py: Refactor/simplify for Python 3.5.
parent
fd2b71f9
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
7 additions
and
6 deletions
+7
-6
examples/network/http_server.py
examples/network/http_server.py
+7
-6
No files found.
examples/network/http_server.py
View file @
aa3fb7b3
...
...
@@ -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
()
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment