Skip to content

Commit ec5f8db

Browse files
committed
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.
1 parent c07a03a commit ec5f8db

1 file changed

Lines changed: 3 additions & 2 deletions

File tree

examples/network/http_server.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,14 +13,15 @@
1313
def main(use_stream=False):
1414
s = socket.socket()
1515

16-
ai = socket.getaddrinfo("127.0.0.1", 8080)
16+
# Binding to all interfaces - server will be accessible to other hosts!
17+
ai = socket.getaddrinfo("0.0.0.0", 8080)
1718
print("Bind address info:", ai)
1819
addr = ai[0][4]
1920

2021
s.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
2122
s.bind(addr)
2223
s.listen(5)
23-
print("Listening, connect your browser to http://127.0.0.1:8080/")
24+
print("Listening, connect your browser to http://<this_host>:8080/")
2425

2526
counter = 0
2627
while True:

0 commit comments

Comments
 (0)