diff --git a/backend/config.py b/backend/config.py index 4e31b09..12af111 100644 --- a/backend/config.py +++ b/backend/config.py @@ -44,7 +44,7 @@ proxy_server = os.environ.get("PROXY_SERVER") class ProxyCreateLink(pydantic.BaseModel): upstream: pydantic.HttpUrl ctype: Optional[pydantic.StrictStr] - region: pydantic.StrictStr + region: Optional[pydantic.StrictStr] class ProxyRequest(pydantic.BaseModel): @@ -75,10 +75,16 @@ class ProxyElem: for url in urls: if isinstance(url, tuple): clean_urls.append(url[0]) - link_requests.append(ProxyCreateLink.parse_obj({"upstream": url[0], "ctype": url[1], "region": self.region})) + link_requests.append( + ProxyCreateLink.parse_obj( + {"upstream": url[0], "ctype": url[1], "region": self.region} + ) + ) else: clean_urls.append(url) - link_requests.append(ProxyCreateLink.parse_obj({"upstream": url, "region": self.region})) + link_requests.append( + ProxyCreateLink.parse_obj({"upstream": url, "region": self.region}) + ) if not isinstance(proxy_server, str): return clean_urls @@ -86,7 +92,9 @@ class ProxyElem: response_data: ProxyResponse try: - request_data = ProxyRequest.parse_obj({"urls": link_requests, "action": "create-urls"}) + request_data = ProxyRequest.parse_obj( + {"urls": link_requests, "action": "create-urls"} + ) except pydantic.ValidationError as e: logger.info(e) return clean_urls @@ -94,7 +102,9 @@ class ProxyElem: try: async with self.local() as session: resp = await session.post(proxy_server, json=request_data) - response_data = cast(ProxyResponse, ProxyResponse.parse_obj(await resp.text())) + response_data = cast( + ProxyResponse, ProxyResponse.parse_obj(await resp.text()) + ) except Exception as e: logger.info(e) else: