Created
April 10, 2018 12:04
-
-
Save aallan/9416763d42534ae99f6f0228f54160c9 to your computer and use it in GitHub Desktop.
A non-caching version of Python's SimpleHTTPServer
This file contains hidden or 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 python | |
import SimpleHTTPServer | |
class MyHTTPRequestHandler(SimpleHTTPServer.SimpleHTTPRequestHandler): | |
def end_headers(self): | |
self.send_my_headers() | |
SimpleHTTPServer.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__': | |
SimpleHTTPServer.test(HandlerClass=MyHTTPRequestHandler) |
Cheers! This works perfectly! Thank you. 😄
THANK YOU 😭
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This only works with python 2.x, use this modification for it to work with v2 or v3