mirror of
https://github.com/exchanges-lab/view.git
synced 2026-08-04 21:31:22 +08:00
26 lines
820 B
Python
26 lines
820 B
Python
#!/usr/bin/env python3
|
|
"""Simple HTTP server for frontend development"""
|
|
|
|
import http.server
|
|
import socketserver
|
|
|
|
PORT = 8080
|
|
|
|
class Handler(http.server.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()
|
|
|
|
if __name__ == '__main__':
|
|
socketserver.TCPServer.allow_reuse_address = True
|
|
with socketserver.TCPServer(('', PORT), Handler) as httpd:
|
|
print(f'Serving at http://localhost:{PORT}')
|
|
print('Press Ctrl+C to stop')
|
|
try:
|
|
httpd.serve_forever()
|
|
except KeyboardInterrupt:
|
|
print('\nStopping...')
|
|
httpd.shutdown()
|