diff --git a/lightly/api/serve.py b/lightly/api/serve.py index cd9fa8b01..ba7bb5fe1 100644 --- a/lightly/api/serve.py +++ b/lightly/api/serve.py @@ -1,4 +1,3 @@ -import re from http.server import HTTPServer, SimpleHTTPRequestHandler from pathlib import Path from typing import Sequence @@ -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)