Skip to content
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 35 additions & 0 deletions office_server.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
#!/usr/bin/env python3
"""3D Office Dashboard Server"""
import http.server
import socketserver
import os
from pathlib import Path
from urllib.parse import urlparse

PORT = 9502
DIRECTORY = Path(__file__).parent

class Handler(http.server.SimpleHTTPRequestHandler):
def __init__(self, *args, **kwargs):
super().__init__(*args, directory=str(DIRECTORY), **kwargs)

def do_GET(self):
parsed = urlparse(self.path)
if parsed.path in ('', '/'):
self.path = '/office.html' + ('?' + parsed.query if parsed.query else '')
return super().do_GET()

def end_headers(self):
self.send_header('Access-Control-Allow-Origin', '*')
self.send_header('Cache-Control', 'no-cache, no-store, must-revalidate')
self.send_header('Pragma', 'no-cache')
self.send_header('Expires', '0')
super().end_headers()

if __name__ == '__main__':
os.chdir(DIRECTORY)
socketserver.TCPServer.allow_reuse_address = True
with socketserver.TCPServer(("", PORT), Handler) as httpd:
print(f"3D Office Dashboard running at http://0.0.0.0:{PORT}")
print(f"Tailscale URL: http://<tailscale-ip>:{PORT}")
httpd.serve_forever()
Loading