Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -486,9 +486,9 @@ def scrap(link_scrap,backlink,keyword,version,api_key,azure_api_base,replicate_k
|
|
486 |
repo_type="space",
|
487 |
token="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",
|
488 |
)
|
489 |
-
|
490 |
-
|
491 |
-
return
|
492 |
# except:
|
493 |
# gambar = Image.open('error.png')
|
494 |
# return gambar
|
@@ -533,20 +533,16 @@ def post(endpoint,endpoint_media,username,password,tags,categories,metode):
|
|
533 |
response_post = requests.post(endpoint, headers=headers, data=data)
|
534 |
return response_post.json()
|
535 |
|
536 |
-
def
|
537 |
with open('judul.txt', 'r') as file:
|
538 |
judul = file.read()
|
539 |
title = '<h1>'+judul+'</h1>'
|
540 |
with open('kontent.txt', 'r') as file:
|
541 |
kontent = file.read()
|
542 |
-
|
|
|
|
|
543 |
|
544 |
-
def raw_text_view():
|
545 |
-
with open('judul.txt', 'r') as file:
|
546 |
-
judul = file.read()
|
547 |
-
with open('kontent.txt', 'r') as file:
|
548 |
-
kontent = file.read()
|
549 |
-
return judul,kontent
|
550 |
|
551 |
with gr.Blocks(theme = "soft", title="Wordpress Article Generator") as article_generator:
|
552 |
gr.HTML(
|
@@ -567,18 +563,18 @@ with gr.Blocks(theme = "soft", title="Wordpress Article Generator") as article_g
|
|
567 |
link_azure = gr.Textbox(placeholder="Khusus Untuk Skema Request Menggunakan Azure", label="Azure Endpoint (Opsional)")
|
568 |
replicate_token = gr.Textbox(placeholder="Masukkan Token Replicate", label="Replicate Key")
|
569 |
button_scrap = gr.Button("Scrap Article")
|
570 |
-
|
571 |
-
|
572 |
with gr.Tab("View_HTML"):
|
573 |
-
html_button = gr.Button("View Output HTML")
|
574 |
title = gr.HTML("")
|
|
|
575 |
content = gr.HTML("")
|
576 |
-
|
577 |
with gr.Tab("View_Raw_Text"):
|
578 |
-
raw_button = gr.Button("View Raw Text")
|
579 |
title = gr.Textbox("", label="Judul")
|
|
|
580 |
content = gr.Textbox("", label="Konten")
|
581 |
-
|
582 |
with gr.Column():
|
583 |
endpoint= gr.Textbox(placeholder="Masukkan Endpoint Wordpress", label="Endpoint Wordpress")
|
584 |
endpoint_media= gr.Textbox(placeholder="Masukkan Endpoint Media Wordpress", label="Endpoint Media")
|
|
|
486 |
repo_type="space",
|
487 |
token="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",
|
488 |
)
|
489 |
+
if kontent:
|
490 |
+
status = "Berhasil Generate Artikel"
|
491 |
+
return status
|
492 |
# except:
|
493 |
# gambar = Image.open('error.png')
|
494 |
# return gambar
|
|
|
533 |
response_post = requests.post(endpoint, headers=headers, data=data)
|
534 |
return response_post.json()
|
535 |
|
536 |
+
def view_outputs():
|
537 |
with open('judul.txt', 'r') as file:
|
538 |
judul = file.read()
|
539 |
title = '<h1>'+judul+'</h1>'
|
540 |
with open('kontent.txt', 'r') as file:
|
541 |
kontent = file.read()
|
542 |
+
with open('image_data.txt', 'rb') as file:
|
543 |
+
file_content = file.read()
|
544 |
+
return title,file_content,kontent
|
545 |
|
|
|
|
|
|
|
|
|
|
|
|
|
546 |
|
547 |
with gr.Blocks(theme = "soft", title="Wordpress Article Generator") as article_generator:
|
548 |
gr.HTML(
|
|
|
563 |
link_azure = gr.Textbox(placeholder="Khusus Untuk Skema Request Menggunakan Azure", label="Azure Endpoint (Opsional)")
|
564 |
replicate_token = gr.Textbox(placeholder="Masukkan Token Replicate", label="Replicate Key")
|
565 |
button_scrap = gr.Button("Scrap Article")
|
566 |
+
button_scrap.click(fn=scrap, inputs=[link,backlink,keyword,versi,api_key,link_azure,replicate_token], outputs=img)
|
567 |
+
view_output = gr.Button("View Output")
|
568 |
with gr.Tab("View_HTML"):
|
|
|
569 |
title = gr.HTML("")
|
570 |
+
img = gr.Image()
|
571 |
content = gr.HTML("")
|
572 |
+
view_output.click(fn=view_outputs, outputs = [title,img,content])
|
573 |
with gr.Tab("View_Raw_Text"):
|
|
|
574 |
title = gr.Textbox("", label="Judul")
|
575 |
+
img = gr.Image()
|
576 |
content = gr.Textbox("", label="Konten")
|
577 |
+
view_output.click(fn=view_outputs, outputs = [title,img,content])
|
578 |
with gr.Column():
|
579 |
endpoint= gr.Textbox(placeholder="Masukkan Endpoint Wordpress", label="Endpoint Wordpress")
|
580 |
endpoint_media= gr.Textbox(placeholder="Masukkan Endpoint Media Wordpress", label="Endpoint Media")
|