added cache-control headers to python web server

This commit is contained in:
Steven Hugg 2018-11-29 21:41:55 -05:00
parent c0d9bac039
commit b397406f45
2 changed files with 18 additions and 3 deletions

View File

@ -24,10 +24,9 @@ archive:
web:
ifconfig | grep inet
python2 -m SimpleHTTPServer 2>> http.out
python3 scripts/serveit.py 2>> http.out
tsweb:
ifconfig | grep inet
$(TSC) -w &
python2 -m SimpleHTTPServer 2>> http.out
#node ../nodejs-typescript-webserver/bin/FileServer.js .
python3 scripts/serveit.py 2>> http.out

16
scripts/serveit.py Executable file
View File

@ -0,0 +1,16 @@
#!/usr/bin/env python3
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)