How Do I Map Incoming "path" Requests When Using Httpserver?
I'm fairly new to coding in python. I created a local web server that says 'Hello World' and displays the current time. Is there a way to create a path, without creating a file, o
Solution 1:
Very simple URL handler:
def do_GET(self):
if self.path == '/time':
do_time(self)
elif self.path == '/date':
do_date(self)
def do_time(self):
self.send_response(200)
self.send_header('Content-type','text/html')
self.end_headers()
# Send the html message
self.wfile.write("<b> Hello World !</b>"
+ "<br><br>Current time: " + str(datetime.datetime.now()))
Post a Comment for "How Do I Map Incoming "path" Requests When Using Httpserver?"