Skip to content

Instantly share code, notes, and snippets.

View gpaciga's full-sized avatar

Gregory Paciga gpaciga

View GitHub Profile
@gpaciga
gpaciga / simple_cors_server.py
Last active May 17, 2024 05:39 — forked from acdha/simple_cors_server.py
Python 3: serve the current directory as HTTP while setting CORS headers for XHR debugging
#!/usr/bin/env python3
# encoding: utf-8
"""Use instead of `python3 -m http.server` when you need CORS"""
import sys
from http.server import HTTPServer, SimpleHTTPRequestHandler
class CORSRequestHandler(SimpleHTTPRequestHandler):
def end_headers(self):
self.send_header('Access-Control-Allow-Origin', '*')