0

I am trying to create a HTTP server on WAN. Below is code that I got from a youtube tutorial:

from http.server import HTTPServer, BaseHTTPRequestHandler

class Serv(BaseHTTPRequestHandler):
    def do_GET(self):
        if self.path=='/':
            self.path='/index.html'
        try:
            file_to_open=open(self.path[1:]).read()
            self.send_response(200)
        except:
            file_to_open='file not found'
            self.send_response(404)
        self.end_headers()
        self.wfile.write(bytes(file_to_open,'utf-8'))

httpd=HTTPServer(('192.168.1.56',8081),Serv)
httpd.serve_forever()  

This works fine on LAN but there does not seem to be much documentation on getting the server onto WAN. I have done the required port-forwarding configuration on my router to forward my laptop's local IP but on checking with yougetsignal.com, I find that the port is still closed. The local IP is manually assigned and I am confident that there is no overlap with other devices on the local network. But I am lost as to how to continue from here. Any help would be appreciated. Thank you!

Clovis Nyu
  • 27
  • 2
  • 11
  • Have you confirmed that the port is open on your laptop’s firewall? You may want to disable the firewall entirely for testing. – Joel C Jun 26 '18 at 14:37
  • Wow, that was exactly the issue. Can't believe it was something so trivial. Thanks! – Clovis Nyu Jun 26 '18 at 14:52

0 Answers0