heroweb/examples/images/server.py
2024-10-31 07:24:12 +01:00

20 lines
580 B
Python

from http.server import HTTPServer, SimpleHTTPRequestHandler
import sys
class CORSRequestHandler(SimpleHTTPRequestHandler):
def end_headers(self):
self.send_header('Access-Control-Allow-Origin', '*')
super().end_headers()
if __name__ == '__main__':
port = 8000
server_address = ('', port)
httpd = HTTPServer(server_address, CORSRequestHandler)
print(f"Server running on port {port}")
try:
httpd.serve_forever()
except KeyboardInterrupt:
print("\nShutting down server")
httpd.server_close()
sys.exit(0)