Created
October 22, 2022 05:05
-
-
Save oglops/b96bd3aa9f2728d00f08a36e7a3070ef to your computer and use it in GitHub Desktop.
simple http server for testing local sphinx site
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python3 | |
# https://stackoverflow.com/questions/12193803/invoke-python-simplehttpserver-from-command-line-with-no-cache-option | |
# without this, it can not run in bg | |
import os | |
import sys | |
sys.stdout = open(os.devnull, 'w') | |
sys.stderr = open(os.devnull, 'w') | |
import http.server | |
class MyHTTPRequestHandler(http.server.SimpleHTTPRequestHandler): | |
def end_headers(self): | |
self.send_my_headers() | |
http.server.SimpleHTTPRequestHandler.end_headers(self) | |
def send_my_headers(self): | |
self.send_header("Cache-Control", "no-cache, no-store, must-revalidate") | |
self.send_header("Pragma", "no-cache") | |
self.send_header("Expires", "0") | |
if __name__ == '__main__': | |
http.server.test(HandlerClass=MyHTTPRequestHandler) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment