Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from http.server import HTTPServer, SimpleHTTPRequestHandler
- hostName = "localhost"
- hostPort = 3333
- class MyHandler(SimpleHTTPRequestHandler):
- def write(self, s):
- self.wfile.write(bytes(s, "utf-8"))
- def do_GET(self):
- global counter
- counter += 1
- self.send_response(200)
- self.send_header("Content-type", "text/html")
- self.end_headers()
- self.write('<html><body><p>HELLO</p>')
- self.write('<p>' + self.path + '</p>')
- self.write('<p>You are #' + str(counter) + '</p>')
- self.write('</body></html>')
- counter = 0
- myServer = HTTPServer((hostName, hostPort), MyHandler)
- myServer.serve_forever()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement