Skip to content

Commit

Permalink
Guarin lig 3871 lightly serve unsupported method options (#1404)
Browse files Browse the repository at this point in the history
* Handle OPTIONS requests in lightly-serve
  • Loading branch information
guarin authored Sep 21, 2023
1 parent 4587ff3 commit f5a3b2e
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions lightly/api/serve.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
import re
from http.server import HTTPServer, SimpleHTTPRequestHandler
from pathlib import Path
from typing import Sequence


def get_server(
paths: Sequence[str],
paths: Sequence[Path],
host: str,
port: int,
):
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(204)
self.send_header("Access-Control-Allow-Origin", "*")
self.send_header("Access-Control-Allow-Methods", "GET, POST, OPTIONS")
self.end_headers()

return HTTPServer((host, port), _LocalDatasourceRequestHandler)


Expand Down

0 comments on commit f5a3b2e

Please sign in to comment.