I have a small-scale python server to handle some incoming requests over the network.
class MyTCPHandler(socketserver.BaseRequestHandler):
def handle(self):
current_date = date.today()
formatted_date = current_date.strftime("%m/%d/%Y")
...
I am calling the date.today() routine inside the handle() function of the server. The server is instantiated and launched in the main function here:
if __name__ == "__main__":
HOST, PORT = "169.229.130.11", 8000
# Create the server, binding to localhost on port 8000
server = socketserver.TCPServer((HOST, PORT), MyTCPHandler)
# Activate the server; this will keep running until you
# interrupt the program with Ctrl-C
server.serve_forever()
It looks like the date.today() function is returning the date that the python program was started on the command line, which was several weeks ago.
If handle() is called for each incoming request to the server, why is date.today() not refreshing?