From ec5f8db49de83d131a8507caba3681e224b11988 Mon Sep 17 00:00:00 2001 From: Paul Sokolovsky Date: Sat, 2 Apr 2016 23:14:19 +0300 Subject: [PATCH] examples/http_server.py: Bind to 0.0.0.0, to be accessible from other hosts. This is helpful when running on deeply embedded targets, but may be "security risk". Caveat emptor. --- examples/network/http_server.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/examples/network/http_server.py b/examples/network/http_server.py index 20f33e5dd3..eb9b5fc3b8 100644 --- a/examples/network/http_server.py +++ b/examples/network/http_server.py @@ -13,14 +13,15 @@ Hello #%d from MicroPython! def main(use_stream=False): s = socket.socket() - ai = socket.getaddrinfo("127.0.0.1", 8080) + # Binding to all interfaces - server will be accessible to other hosts! + ai = socket.getaddrinfo("0.0.0.0", 8080) print("Bind address info:", ai) addr = ai[0][4] s.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1) s.bind(addr) s.listen(5) - print("Listening, connect your browser to http://127.0.0.1:8080/") + print("Listening, connect your browser to http://:8080/") counter = 0 while True: