22 lines
763 B
Python
Executable File
22 lines
763 B
Python
Executable File
#!/usr/bin/env python3
|
|
import http.server
|
|
import socketserver
|
|
from functools import partial
|
|
|
|
class CORSRequestHandler(http.server.SimpleHTTPRequestHandler):
|
|
def end_headers(self):
|
|
self.send_header('Access-Control-Allow-Origin', '*')
|
|
self.send_header('Access-Control-Allow-Methods', 'GET')
|
|
self.send_header('Cache-Control', 'no-store, no-cache, must-revalidate')
|
|
super().end_headers()
|
|
|
|
PORT = 8080
|
|
handler = partial(CORSRequestHandler, directory='/home/alex/git/carrot/Carrot_Hunter')
|
|
|
|
print(f"\n✓ Server kører på http://localhost:{PORT}")
|
|
print(f"✓ Åbn: http://localhost:{PORT}/index.html")
|
|
print(f"✓ Med CORS headers aktiveret\n")
|
|
|
|
with socketserver.TCPServer(("", PORT), handler) as httpd:
|
|
httpd.serve_forever()
|