Skip to content

Commit

Permalink
Handle lightly-serve OPTIONS requests
Browse files Browse the repository at this point in the history
  • Loading branch information
guarin committed Sep 21, 2023
1 parent b6bf5d1 commit 12ca7b4
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion lightly/api/serve.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import re
from http.server import HTTPServer, SimpleHTTPRequestHandler
from pathlib import Path
from typing import Sequence
Expand Down Expand Up @@ -34,6 +33,12 @@ class _LocalDatasourceRequestHandler(SimpleHTTPRequestHandler):
def translate_path(self, path: str) -> str:
return _translate_path(path=path, directories=paths)

def do_OPTIONS(self) -> None:
self.send_response(200, "ok")
self.send_header("Access-Control-Allow-Origin", self.headers["origin"])
self.send_header("Access-Control-Allow-Methods", "GET, POST, OPTIONS")
self.send_header("Access-Control-Allow-Headers", "x-requested-with")

return HTTPServer((host, port), _LocalDatasourceRequestHandler)


Expand Down

0 comments on commit 12ca7b4

Please sign in to comment.