diff --git a/.replit b/.replit index 60cd8ed..6f175b6 100644 --- a/.replit +++ b/.replit @@ -16,14 +16,14 @@ args = "Start application" name = "Start application" author = "agent" -[[workflows.workflow.tasks]] -task = "shell.exec" -args = "python3 -m http.server 5000" -waitForPort = 5000 - [workflows.workflow.metadata] outputType = "webview" +[[workflows.workflow.tasks]] +task = "shell.exec" +args = "python3 serve.py" +waitForPort = 5000 + [[ports]] localPort = 5000 externalPort = 80 diff --git a/serve.py b/serve.py new file mode 100644 index 0000000..6e11caa --- /dev/null +++ b/serve.py @@ -0,0 +1,18 @@ +import http.server +import socketserver + +PORT = 5000 + +class NoCacheHandler(http.server.SimpleHTTPRequestHandler): + def end_headers(self): + self.send_header('Cache-Control', 'no-store, no-cache, must-revalidate, max-age=0') + self.send_header('Pragma', 'no-cache') + self.send_header('Expires', '0') + super().end_headers() + +class ReusableTCPServer(socketserver.TCPServer): + allow_reuse_address = True + +with ReusableTCPServer(("0.0.0.0", PORT), NoCacheHandler) as httpd: + print(f"Serving on port {PORT} with cache disabled") + httpd.serve_forever()