-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathwebreport.py
More file actions
27 lines (22 loc) · 795 Bytes
/
Copy pathwebreport.py
File metadata and controls
27 lines (22 loc) · 795 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
import http.server
import socketserver
import webbrowser
import os
from threading import Timer
PORT = 8000
HOST = "localhost"
class Handler(http.server.SimpleHTTPRequestHandler):
def __init__(self, *args, **kwargs):
super().__init__(*args, directory=os.getcwd(), **kwargs)
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()
def start_server():
with socketserver.TCPServer((HOST, PORT), Handler) as httpd:
print(f"Serving at http://{HOST}:{PORT}")
webbrowser.open_new_tab(f"http://{HOST}:{PORT}")
httpd.serve_forever()
if __name__ == "__main__":
start_server()