I finished making a basic web server a little while ago, however I cannot access it at all. I ran it on my mac, which didn't work. I then ran it on my PC and tried to access it from my mac using Firefox.
This is the code I have for the server:
from http.server import HTTPServer, BaseHTTPRequestHandler class RequestHandler(BaseHTTPRequestHandler): def _writeheaders(self): self.send_response(200) self.send_header('Content-type', 'text/html') self.end_headers() def do_HEAD(self): self._writeheaders() def do_GET(self): self._writeheaders() self.wfile.write("""<HTML> <HEAD><TITLE>Sample title</TITLE></HEAD> <BODY>sample text</BODY> </HTML>""") serveraddr = ('', 8080) srvr = HTTPServer(serveraddr, RequestHandler) print("Server online and active") srvr.serve_forever()
Here's the error I got from Firefox:
Failed to Connect
Firefox can't establish a connection to the server at ##.#.#.#:8080.
Though the site seems valid, the browser was unable to establish a connection.
* Could the site be temporarily unavailable? Try again later.
* Are you unable to browse other sites? Check the computer's network connection.
* Is your computer or network protected by a firewall or proxy? Incorrect settings can interfere with Web browsing
and here's what I got with safari:
Safari can’t connect to the server.
Safari can’t open the page “http://##.#.#.#:8080/” because it could not connect to the server “##.#.#.#”.
How would I make this accessible remotely?