Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -2,6 +2,8 @@ import gradio as gr
|
|
2 |
import requests
|
3 |
import json
|
4 |
from PIL import Image
|
|
|
|
|
5 |
main_directory = "https://services.swpc.noaa.gov/"
|
6 |
|
7 |
html = """
|
@@ -111,13 +113,19 @@ def make_animation():
|
|
111 |
spl3 = line2.split(">")[0].strip('""')
|
112 |
if spl3.endswith(".png") or spl3.endswith(".gif") or spl3.endswith(".jpg"):
|
113 |
gif_box.append(f'{get_url}{spl2}{spl3}')
|
114 |
-
|
115 |
-
|
116 |
-
|
117 |
-
|
118 |
-
|
119 |
-
|
120 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
121 |
|
122 |
def run():
|
123 |
out=make_tree()
|
|
|
2 |
import requests
|
3 |
import json
|
4 |
from PIL import Image
|
5 |
+
import urllib.request
|
6 |
+
|
7 |
main_directory = "https://services.swpc.noaa.gov/"
|
8 |
|
9 |
html = """
|
|
|
113 |
spl3 = line2.split(">")[0].strip('""')
|
114 |
if spl3.endswith(".png") or spl3.endswith(".gif") or spl3.endswith(".jpg"):
|
115 |
gif_box.append(f'{get_url}{spl2}{spl3}')
|
116 |
+
|
117 |
+
#frames = [Image.open(image) for image in glob.glob(f"{frame_folder}/*.JPG")]
|
118 |
+
frames = []
|
119 |
+
for i,ea in enumerate(gif_box):
|
120 |
+
urllib.request.urlretrieve(ea,f'tmp{i}.png')
|
121 |
+
frames.append(Image.open("gfg.png"))
|
122 |
+
frame_one = frames[0]
|
123 |
+
filename=f'{spl3.split(".")[0]}.gif'
|
124 |
+
frame_one.save(filename, format="GIF", append_images=frames,
|
125 |
+
save_all=True, duration=100, loop=0)
|
126 |
+
html_out+=f'<div class="img_class"><img src="{filename}"></div>'
|
127 |
+
|
128 |
+
return html_out
|
129 |
|
130 |
def run():
|
131 |
out=make_tree()
|