File: start_http.py

package info (click to toggle)
python-pywebview 6.0%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 33,436 kB
  • sloc: python: 10,230; javascript: 3,185; java: 522; cs: 130; sh: 16; makefile: 3
file content (15 lines) | stat: -rwxr-xr-x 569 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
"""
This script starts a simple no-caching HTTP server that serves files from the current directory.
"""
from http import server
import os

class NoCacheHTTPRequestHandler(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()

os.chdir(os.path.dirname(os.path.abspath(__file__)))
server.HTTPServer(("", 1234), NoCacheHTTPRequestHandler).serve_forever()