mirror of
https://github.com/sehugg/8bitworkshop.git
synced 2025-02-23 03:29:05 +00:00
added cache-control headers to python web server
This commit is contained in:
parent
c0d9bac039
commit
b397406f45
5
Makefile
5
Makefile
@ -24,10 +24,9 @@ archive:
|
|||||||
|
|
||||||
web:
|
web:
|
||||||
ifconfig | grep inet
|
ifconfig | grep inet
|
||||||
python2 -m SimpleHTTPServer 2>> http.out
|
python3 scripts/serveit.py 2>> http.out
|
||||||
|
|
||||||
tsweb:
|
tsweb:
|
||||||
ifconfig | grep inet
|
ifconfig | grep inet
|
||||||
$(TSC) -w &
|
$(TSC) -w &
|
||||||
python2 -m SimpleHTTPServer 2>> http.out
|
python3 scripts/serveit.py 2>> http.out
|
||||||
#node ../nodejs-typescript-webserver/bin/FileServer.js .
|
|
||||||
|
16
scripts/serveit.py
Executable file
16
scripts/serveit.py
Executable 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)
|
Loading…
x
Reference in New Issue
Block a user