移除一键保本bug
This commit is contained in:
@@ -336,7 +336,12 @@ def _parse_http_json_body(r: httpx.Response) -> dict:
|
||||
|
||||
|
||||
async def _fetch_flask_json(
|
||||
client: httpx.AsyncClient, ex: dict, path: str, method: str = "GET", data=None
|
||||
client: httpx.AsyncClient,
|
||||
ex: dict,
|
||||
path: str,
|
||||
method: str = "GET",
|
||||
data=None,
|
||||
json_body: dict | None = None,
|
||||
) -> dict | None:
|
||||
base = (ex.get("flask_url") or "").rstrip("/")
|
||||
if not base:
|
||||
@@ -345,7 +350,15 @@ async def _fetch_flask_json(
|
||||
if method == "GET":
|
||||
r = await client.get(f"{base}{path}", headers=_hub_headers(), timeout=HUB_FLASK_TIMEOUT)
|
||||
else:
|
||||
r = await client.post(f"{base}{path}", headers=_hub_headers(), data=data, timeout=120.0)
|
||||
headers = {**_hub_headers(), "Content-Type": "application/json"}
|
||||
if json_body is not None:
|
||||
r = await client.post(
|
||||
f"{base}{path}", headers=headers, json=json_body, timeout=120.0
|
||||
)
|
||||
else:
|
||||
r = await client.post(
|
||||
f"{base}{path}", headers=headers, data=data, timeout=120.0
|
||||
)
|
||||
if r.status_code >= 400:
|
||||
parsed = _parse_http_json_body(r)
|
||||
parsed.setdefault("ok", False)
|
||||
|
||||
Reference in New Issue
Block a user