diff --git a/api/dev_server.py b/api/dev_server.py index ea7d237..290aa96 100644 --- a/api/dev_server.py +++ b/api/dev_server.py @@ -15,34 +15,46 @@ routes = web.RouteTableDef() @routes.get("/{tail:.*}") async def get_handler(request: web.Request) -> web.Response: - data = await request.get() - alog.info("GET -> [%s]: %s", request.path, data) - return web.json_response({"method": request.method, "path": request.path}) + alog.info("GET -> [%s]: %s", request.path, request.query) + return web.json_response( + {"method": request.method, "path": request.path}, + headers={"Access-Control-Allow-Origin": "*"}, + ) @routes.post("/{tail:.*}") async def post_handler(request: web.Request) -> web.Response: data = await request.post() alog.info("POST -> [%s]: %s", request.path, data) - return web.json_response({"method": request.method, "path": request.path}) + return web.json_response( + {"method": request.method, "path": request.path}, + headers={"Access-Control-Allow-Origin": "*"}, + ) @routes.put("/{tail:.*}") async def put_handler(request: web.Request) -> web.Response: - data = await request.put() + data = await request.post() alog.info("PUT -> [%s]: %s", request.path, data) - return web.json_response({"method": request.method, "path": request.path}) + return web.json_response( + {"method": request.method, "path": request.path}, + headers={"Access-Control-Allow-Origin": "*"}, + ) @routes.delete("/{tail:.*}") async def delete_handler(request: web.Request) -> web.Response: - alog.info("DELETE -> [%s]", request.path) - return web.json_response({"method": request.method, "path": request.path}) + data = await request.post() + alog.info("DELETE -> [%s]: %s", request.path, data) + return web.json_response( + {"method": request.method, "path": request.path}, + headers={"Access-Control-Allow-Origin": "*"}, + ) async def options_handler(request: web.Request) -> web.Response: alog.info("OPTIONS -> [%s]", request.path) - return web.Response(status=200, headers={"Access-Control-Allow-Origin": "*"}) + return web.Response(status=200) def run(address: str, port: int) -> None: