Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -563,7 +563,40 @@ def view_outputs():
|
|
563 |
kontent = 'Gagal Generate Konten'
|
564 |
image = Image.open('error.png')
|
565 |
return title,image,kontent
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
566 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
567 |
|
568 |
with gr.Blocks(theme = "soft", title="Wordpress Article Generator") as article_generator:
|
569 |
gr.HTML(
|
@@ -592,11 +625,15 @@ with gr.Blocks(theme = "soft", title="Wordpress Article Generator") as article_g
|
|
592 |
img = gr.Image()
|
593 |
content = gr.HTML("")
|
594 |
view_output.click(fn=view_outputs, outputs = [title,img,content])
|
|
|
|
|
595 |
with gr.Tab("Raw Output"):
|
596 |
title = gr.Textbox("", label="Judul", interactive=True)
|
597 |
img = gr.Image(height=300, width=500)
|
598 |
content = gr.Textbox("", label="Konten", interactive=True)
|
599 |
view_output.click(fn=view_outputs, outputs = [title,img,content])
|
|
|
|
|
600 |
with gr.Column():
|
601 |
endpoint= gr.Textbox(placeholder="Masukkan Endpoint Wordpress", label="Endpoint Wordpress")
|
602 |
endpoint_media= gr.Textbox(placeholder="Masukkan Endpoint Media Wordpress", label="Endpoint Media")
|
|
|
563 |
kontent = 'Gagal Generate Konten'
|
564 |
image = Image.open('error.png')
|
565 |
return title,image,kontent
|
566 |
+
|
567 |
+
def save(title,content):
|
568 |
+
with open("judul.txt", "w") as file:
|
569 |
+
file.write(judul)
|
570 |
+
|
571 |
+
with open("kontent.txt", "w") as file:
|
572 |
+
file.write(content)
|
573 |
|
574 |
+
repo_name = get_full_repo_name(model_id="Article_Gen3", token="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")
|
575 |
+
file_url = upload_file(
|
576 |
+
path_or_fileobj='judul.txt',
|
577 |
+
path_in_repo="judul.txt",
|
578 |
+
repo_id=repo_name,
|
579 |
+
repo_type="space",
|
580 |
+
token="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",
|
581 |
+
)
|
582 |
+
file_url = upload_file(
|
583 |
+
path_or_fileobj='kontent.txt',
|
584 |
+
path_in_repo="kontent.txt",
|
585 |
+
repo_id=repo_name,
|
586 |
+
repo_type="space",
|
587 |
+
token="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",
|
588 |
+
)
|
589 |
+
|
590 |
+
def view():
|
591 |
+
with open('judul.txt', 'r') as file:
|
592 |
+
judul = file.read()
|
593 |
+
title = '<h1>'+judul+'</h1>'
|
594 |
+
with open('kontent.txt', 'r') as file:
|
595 |
+
kontent = file.read()
|
596 |
+
image = Image.open('output_image.png')
|
597 |
+
|
598 |
+
return title,image,kontent
|
599 |
+
|
600 |
|
601 |
with gr.Blocks(theme = "soft", title="Wordpress Article Generator") as article_generator:
|
602 |
gr.HTML(
|
|
|
625 |
img = gr.Image()
|
626 |
content = gr.HTML("")
|
627 |
view_output.click(fn=view_outputs, outputs = [title,img,content])
|
628 |
+
view_change = gr.Button("View Change")
|
629 |
+
view_change.click(fn=view, outputs=[title,img,content])
|
630 |
with gr.Tab("Raw Output"):
|
631 |
title = gr.Textbox("", label="Judul", interactive=True)
|
632 |
img = gr.Image(height=300, width=500)
|
633 |
content = gr.Textbox("", label="Konten", interactive=True)
|
634 |
view_output.click(fn=view_outputs, outputs = [title,img,content])
|
635 |
+
save_button= gr.Button("Save Changes")
|
636 |
+
save_button.click(fn=save, inputs =[title,content])
|
637 |
with gr.Column():
|
638 |
endpoint= gr.Textbox(placeholder="Masukkan Endpoint Wordpress", label="Endpoint Wordpress")
|
639 |
endpoint_media= gr.Textbox(placeholder="Masukkan Endpoint Media Wordpress", label="Endpoint Media")
|