I'm running a local server using http.server
like this:
from http.server import HTTPServer, BaseHTTPRequestHandler
class ServerHandler(BaseHTTPRequestHandler):
def do_POST(self):
...
if __name__ == "__main__":
print("Starting server at "+str(PORT)+"...")
server = HTTPServer(('', PORT), ServerHandler)
server.serve_forever()
I want to invoke a function before stopping the server using Ctrl+C in the terminal
how do I do so?