Initial commit - QBPOS Help
This commit is contained in:
39
python/server.py
Normal file
39
python/server.py
Normal file
@@ -0,0 +1,39 @@
|
||||
#!/usr/bin/env python3
|
||||
"""
|
||||
Simple HTTP Server for QuickBooks POS Help Documentation
|
||||
Access via: http://localhost:8888
|
||||
"""
|
||||
import http.server
|
||||
import socketserver
|
||||
import os
|
||||
from datetime import datetime
|
||||
|
||||
PORT = 8888
|
||||
DIRECTORY = "QB_Help_Web"
|
||||
|
||||
class MyHTTPRequestHandler(http.server.SimpleHTTPRequestHandler):
|
||||
def __init__(self, *args, **kwargs):
|
||||
super().__init__(*args, directory=DIRECTORY, **kwargs)
|
||||
|
||||
def end_headers(self):
|
||||
# Disable caching for development
|
||||
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()
|
||||
|
||||
os.chdir(os.path.dirname(os.path.abspath(__file__)))
|
||||
|
||||
# Use ThreadingTCPServer for better responsiveness
|
||||
class ThreadedTCPServer(socketserver.ThreadingMixIn, socketserver.TCPServer):
|
||||
allow_reuse_address = True
|
||||
|
||||
with ThreadedTCPServer(("0.0.0.0", PORT), MyHTTPRequestHandler) as httpd:
|
||||
print(f"Server running at:")
|
||||
print(f" Local access: http://localhost:{PORT}/POS_Help.html")
|
||||
print(f" Network access: http://192.168.10.130:{PORT}/POS_Help.html")
|
||||
print(f"\nFeatures:")
|
||||
print(f" - No caching (instant updates)")
|
||||
print(f" - Multi-threaded (faster response)")
|
||||
print(f"\nPress Ctrl+C to stop the server")
|
||||
httpd.serve_forever()
|
||||
Reference in New Issue
Block a user