23 lines
796 B
Python
23 lines
796 B
Python
#!/usr/bin/env python3
|
||
"""Минимальный HTTP-сервер для /data с заголовками no-cache, чтобы браузер не кэшировал страницу."""
|
||
import http.server
|
||
import os
|
||
|
||
DIR = os.environ.get("SERVE_DIR", "/data")
|
||
PORT = int(os.environ.get("SERVE_PORT", "8765"))
|
||
|
||
|
||
class NoCacheHandler(http.server.SimpleHTTPRequestHandler):
|
||
def __init__(self, *args, **kwargs):
|
||
super().__init__(*args, directory=DIR, **kwargs)
|
||
|
||
def end_headers(self):
|
||
self.send_header("Cache-Control", "no-store, no-cache, must-revalidate")
|
||
self.send_header("Pragma", "no-cache")
|
||
self.send_header("Expires", "0")
|
||
super().end_headers()
|
||
|
||
|
||
if __name__ == "__main__":
|
||
http.server.HTTPServer(("", PORT), NoCacheHandler).serve_forever()
|