79527243

Date: 2025-03-22 10:03:35
Score: 1
Natty:
Report link

Since we can assume everyone's on Python 3 by now, the example by @berto in https://stackoverflow.com/a/13354482 can now be considerably shorter:

#!/usr/bin/env python3

from http import server

class MyHTTPRequestHandler(server.SimpleHTTPRequestHandler):
    def end_headers(self):
        self.send_header("Access-Control-Allow-Origin", "*")
        super().end_headers()

server.test(HandlerClass = MyHTTPRequestHandler)

(Note: I was trying to post this as a comment, but you can't have code blocks in comments?)

Reasons:
  • Blacklisted phrase (1): stackoverflow
  • Has code block (-0.5):
  • Contains question mark (0.5):
  • User mentioned (1): @berto
  • High reputation (-1):
Posted by: Florian Echtler