Spaces:
Build error
Build error
Update app.py
Browse files
app.py
CHANGED
@@ -216,9 +216,21 @@ def preview_img(im):
|
|
216 |
out = f"""<body><div><img src={im}></div></body>"""
|
217 |
print(out)
|
218 |
return out
|
219 |
-
def prepare_card(title,description,img):
|
220 |
-
|
221 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
222 |
with gr.Blocks() as app:
|
223 |
gr.HTML("""<h1>Interactive Social Media Card Maker</h1>""")
|
224 |
gr.HTML("""<h3><b>Step 1:</b> Enter a URL with Iframe capability</h3>""")
|
@@ -242,7 +254,8 @@ with gr.Blocks() as app:
|
|
242 |
title=gr.Textbox(label="Title")
|
243 |
description=gr.Textbox(label="Description")
|
244 |
link_list=gr.Textbox(label="Image URL")
|
245 |
-
|
|
|
246 |
|
247 |
#img_card=gr.Image()
|
248 |
with gr.Column():
|
@@ -256,7 +269,7 @@ with gr.Blocks() as app:
|
|
256 |
app.load(None,None,link_list,js=link_js)
|
257 |
grab_im_url_btn.click(None,None,[link_list],js=link_js)
|
258 |
preview_image_btn.click(preview_img,link_list,img_card)
|
259 |
-
prepare_btn.click(prepare_card,
|
260 |
#images.change(update_im,None,link_list,trigger_mode="multiple",js=link_js)
|
261 |
search_btn.click(search_fn,[search_box,num_return],output)
|
262 |
btn.click(first,None,output).then(test_single,input,output).then(details_fn,input,[details,images,title,description])
|
|
|
216 |
out = f"""<body><div><img src={im}></div></body>"""
|
217 |
print(out)
|
218 |
return out
|
219 |
+
def prepare_card(url,title,description,img):
|
220 |
+
|
221 |
+
with open("template.html", "r") as f:
|
222 |
+
app = f.read()
|
223 |
+
app = app.replace("$space", url)
|
224 |
+
app = app.replace("$title", title)
|
225 |
+
app = app.replace("$description", description)
|
226 |
+
app = app.replace("$image", img)
|
227 |
+
app = app.replace("$redirect", url)
|
228 |
+
|
229 |
+
#with open("ai.html", "w") as f:
|
230 |
+
# f.write(app)
|
231 |
+
#files.append("ai.html")
|
232 |
+
return(app)
|
233 |
+
|
234 |
with gr.Blocks() as app:
|
235 |
gr.HTML("""<h1>Interactive Social Media Card Maker</h1>""")
|
236 |
gr.HTML("""<h3><b>Step 1:</b> Enter a URL with Iframe capability</h3>""")
|
|
|
254 |
title=gr.Textbox(label="Title")
|
255 |
description=gr.Textbox(label="Description")
|
256 |
link_list=gr.Textbox(label="Image URL")
|
257 |
+
with gr.Accordiong("Image Preview"):
|
258 |
+
img_card=gr.HTML("""""")
|
259 |
|
260 |
#img_card=gr.Image()
|
261 |
with gr.Column():
|
|
|
269 |
app.load(None,None,link_list,js=link_js)
|
270 |
grab_im_url_btn.click(None,None,[link_list],js=link_js)
|
271 |
preview_image_btn.click(preview_img,link_list,img_card)
|
272 |
+
prepare_btn.click(prepare_card,[title,description,link_list],[prepared_html])
|
273 |
#images.change(update_im,None,link_list,trigger_mode="multiple",js=link_js)
|
274 |
search_btn.click(search_fn,[search_box,num_return],output)
|
275 |
btn.click(first,None,output).then(test_single,input,output).then(details_fn,input,[details,images,title,description])
|