Skip to content

Commit

Permalink
serve local set port
Browse files Browse the repository at this point in the history
dragazo committed Dec 19, 2023
1 parent 1758a51 commit b3b0693
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion serve-local.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,14 @@
from http.server import HTTPServer, SimpleHTTPRequestHandler, test
import argparse

class CORSRequestHandler(SimpleHTTPRequestHandler):
def end_headers(self) -> None:
self.send_header('Access-Control-Allow-Origin', '*')
super().end_headers()

if __name__ == '__main__':
test(CORSRequestHandler, HTTPServer)
parser = argparse.ArgumentParser()
parser.add_argument('-p', '--port', type = int, default = 8000)
args = parser.parse_args()

test(CORSRequestHandler, HTTPServer, port = args.port)

0 comments on commit b3b0693

Please sign in to comment.