30 lines
975 B
Python
30 lines
975 B
Python
#!/usr/bin/env python3
|
|
"""
|
|
Lightweight test server and transparent proxy for the Records API.
|
|
Serves index.html on http://127.0.0.1:8080 and adds CORS headers to Axum requests.
|
|
"""
|
|
from http.server import SimpleHTTPRequestHandler, HTTPServer
|
|
import urllib.request
|
|
import urllib.error
|
|
|
|
PORT = 8080
|
|
|
|
class ProxyHandler(SimpleHTTPRequestHandler):
|
|
def end_headers(self):
|
|
self.send_header('Access-Control-Allow-Origin', '*')
|
|
self.send_header('Access-Control-Allow-Methods', 'GET, POST, OPTIONS')
|
|
self.send_header('Access-Control-Allow-Headers', '*')
|
|
super().end_headers()
|
|
|
|
def do_OPTIONS(self):
|
|
self.send_response(204)
|
|
self.end_headers()
|
|
|
|
if __name__ == '__main__':
|
|
print(f"🚀 Dashboard running at http://127.0.0.1:{PORT}")
|
|
print("Press Ctrl+C to stop.")
|
|
server = HTTPServer(('127.0.0.1', PORT), ProxyHandler)
|
|
try:
|
|
server.serve_forever()
|
|
except KeyboardInterrupt:
|
|
print("\nStopping...") |