mirror of
https://github.com/gradio-app/gradio.git
synced 2025-04-12 12:40:29 +08:00
Replace httpx with requests library in save_url_to_cache to make it work in wasm mode (#7725)
* Replace httpx with requests library to make it work in wasm mode * add changeset --------- Co-authored-by: gradio-pr-bot <gradio-pr-bot@users.noreply.github.com>
This commit is contained in:
parent
aca4892ea5
commit
181f4d05d4
5
.changeset/spotty-parents-wink.md
Normal file
5
.changeset/spotty-parents-wink.md
Normal file
@ -0,0 +1,5 @@
|
||||
---
|
||||
"gradio": patch
|
||||
---
|
||||
|
||||
fix:Replace httpx with requests library in save_url_to_cache to make it work in wasm mode
|
@ -13,8 +13,8 @@ from io import BytesIO
|
||||
from pathlib import Path
|
||||
from typing import TYPE_CHECKING, Any, Literal
|
||||
|
||||
import httpx
|
||||
import numpy as np
|
||||
import requests
|
||||
from gradio_client import utils as client_utils
|
||||
from PIL import Image, ImageOps, PngImagePlugin
|
||||
|
||||
@ -190,10 +190,9 @@ def save_url_to_cache(url: str, cache_dir: str) -> str:
|
||||
full_temp_file_path = str(abspath(temp_dir / name))
|
||||
|
||||
if not Path(full_temp_file_path).exists():
|
||||
with httpx.stream("GET", url, follow_redirects=True) as r, open(
|
||||
full_temp_file_path, "wb"
|
||||
) as f:
|
||||
for chunk in r.iter_raw():
|
||||
response = requests.get(url, stream=True)
|
||||
with open(full_temp_file_path, "wb") as f:
|
||||
for chunk in response.iter_content(chunk_size=256):
|
||||
f.write(chunk)
|
||||
|
||||
return full_temp_file_path
|
||||
|
Loading…
x
Reference in New Issue
Block a user