Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -65,12 +65,12 @@ image_url4 = "https://cdn-uploads.huggingface.co/production/uploads/620630b60382
|
|
| 65 |
|
| 66 |
# ---- Art Card Sidebar with random selection of image:
|
| 67 |
def get_image_as_base64(url):
|
| 68 |
-
response = requests.get(url)
|
| 69 |
-
if response.status_code == 200:
|
| 70 |
-
|
| 71 |
-
|
| 72 |
-
else:
|
| 73 |
-
|
| 74 |
|
| 75 |
def create_download_link(filename, base64_str):
|
| 76 |
href = f'<a href="data:file/png;base64,{base64_str}" download="{filename}">Download Image</a>'
|
|
|
|
| 65 |
|
| 66 |
# ---- Art Card Sidebar with random selection of image:
|
| 67 |
def get_image_as_base64(url):
|
| 68 |
+
response = requests.get(url)
|
| 69 |
+
if response.status_code == 200:
|
| 70 |
+
# Convert the image to base64
|
| 71 |
+
return base64.b64encode(response.content).decode("utf-8")
|
| 72 |
+
else:
|
| 73 |
+
return None
|
| 74 |
|
| 75 |
def create_download_link(filename, base64_str):
|
| 76 |
href = f'<a href="data:file/png;base64,{base64_str}" download="{filename}">Download Image</a>'
|