Tweaked version of Python's http.server with CORS
This commit is contained in:
parent
b24f37349a
commit
e344a02c65
1 changed files with 11 additions and 0 deletions
11
local/bin/http.server.cors
Executable file
11
local/bin/http.server.cors
Executable file
|
@ -0,0 +1,11 @@
|
|||
#!/usr/bin/env python3
|
||||
from http.server import HTTPServer, SimpleHTTPRequestHandler, test
|
||||
import sys
|
||||
|
||||
class CORSRequestHandler(SimpleHTTPRequestHandler):
|
||||
def end_headers(self):
|
||||
self.send_header('Access-Control-Allow-Origin', '*')
|
||||
super().end_headers()
|
||||
|
||||
if __name__ == '__main__':
|
||||
test(CORSRequestHandler, HTTPServer, port=int(sys.argv[1]) if len(sys.argv) > 1 else 8000)
|
Loading…
Reference in a new issue