Bind HTTServer to local ip: port so others on the local network can see it?

I want to run a simple HTTP server on a local network to check it, how can I bind a local ip to this server so that everyone on the same local network can see it?

 addr = ("192.168.10.14", 8765)
 srvr = HTTPServer(addr,RequestHandler)

I get this error:

error: [Errno 10049] The requested address is invalid in its context

+3
source share
3 answers

try the following:

addr = ("0.0.0.0", 8765)

Here is what I did:

import BaseHTTPServer
from SimpleHTTPServer import SimpleHTTPRequestHandler

addr = ("0.0.0.0", 8765)

serv = BaseHTTPServer.HTTPServer(addr, SimpleHTTPRequestHandler)

serv.serve_forever()

And received from another machine:

192.168.1.2 - - [09/Nov/2010 22:26:09] "GET / HTTP/1.1" 200 -
+12
source

You can bind to all interfaces by leaving your address an empty string

addr = ("", 8765)

, , , - NAT .

+3

Why can't you use python -m SimpleHTTPServer [port]? Python - SimpleHTTPServer

+2
source

Source: https://habr.com/ru/post/1773961/


All Articles