import osfrom http.server import HTTPServer, CGIHTTPRequestHandler# Make sure the server is created at current directoryos.chdir('.')# Create server object listening the port 80server_object = HTTPServer(server_address=('', 80), RequestHandlerClass=CGIHTTPRequestHandler)# Start the web serverserver_object.serve_forever()
# Python 3 server examplefrom http.server import BaseHTTPRequestHandler, HTTPServerimport timehostName = "localhost"serverPort = 8080class MyServer(BaseHTTPRequestHandler): def do_GET(self): self.send_response(200) self.send_header("Content-type", "text/html") self.end_headers() self.wfile.write(bytes("<html><head><title>https://pythonbasics.org</title></head>", "utf-8")) self.wfile.write(bytes("<p>Request: %s</p>" % self.path, "utf-8")) self.wfile.write(bytes("<body>", "utf-8")) self.wfile.write(bytes("<p>This is an example web server.</p>", "utf-8")) self.wfile.write(bytes("</body></html>", "utf-8"))if __name__ == "__main__": webServer = HTTPServer((hostName, serverPort), MyServer) print("Server started http://%s:%s" % (hostName, serverPort)) try: webServer.serve_forever() except KeyboardInterrupt: pass webServer.server_close() print("Server stopped.")
almost looks like we dont need any other programming language than python..
python -m SimpleHTTPServer
<!DOCTYPE html><html><head><link rel="stylesheet" href="style.css"></head><body><h1>This is a heading</h1><p>This is a paragraph.</p></body></html>
body { background-color: powderblue; }h1 { color: blue; }p { color: red; }
Show us on the doll where the bad programming language hurt you
wait a moment ..are you one of this which constantly spreading suchpatronized and insulting ...babeling ..I can only say to you ...PUT THE PIPE DOWN !