20 lines
580 B
Python
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)
|