Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -551,6 +551,29 @@ def post(endpoint,endpoint_media,username,password,tags,categories,metode):
|
|
551 |
credentials = base64.b64encode(f"{username}:{password}".encode("utf-8")).decode("utf-8")
|
552 |
headers = {"Authorization": f"Basic {credentials}"}
|
553 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
554 |
with open('image_data.txt', 'rb') as file:
|
555 |
file_content = file.read()
|
556 |
|
@@ -580,8 +603,8 @@ def post(endpoint,endpoint_media,username,password,tags,categories,metode):
|
|
580 |
"content":kontent,
|
581 |
"featured_media" : media,
|
582 |
"status": metode,
|
583 |
-
"categories":
|
584 |
-
"tags":
|
585 |
}
|
586 |
|
587 |
response_post = requests.post(endpoint, headers=headers, data=data)
|
@@ -676,8 +699,8 @@ with gr.Blocks(theme = "soft", title="Wordpress Article Generator") as article_g
|
|
676 |
endpoint_media= gr.Textbox(placeholder="Masukkan Endpoint Media Wordpress", label="Endpoint Media")
|
677 |
username= gr.Textbox(placeholder="Masukkan Username Wordpress",label="Username")
|
678 |
password= gr.Textbox(placeholder="Masukkan Password Wordpress",type="password" ,label="Password")
|
679 |
-
|
680 |
-
|
681 |
metode= gr.Radio(["publish", "draft"], label="Post Status", info="Pilih Metode Publish atau Draft Untuk Memposting")
|
682 |
button_post = gr.Button("Post Article")
|
683 |
status = gr.Textbox("", label="Response")
|
|
|
551 |
credentials = base64.b64encode(f"{username}:{password}".encode("utf-8")).decode("utf-8")
|
552 |
headers = {"Authorization": f"Basic {credentials}"}
|
553 |
|
554 |
+
tag = tags
|
555 |
+
cat = [categories]
|
556 |
+
|
557 |
+
if 'chatbot' in tag:
|
558 |
+
index = tag.index('chatbot')
|
559 |
+
tag[index] = 13
|
560 |
+
if 'ai' in tags:
|
561 |
+
index = tag.index('ai')
|
562 |
+
tag[index] = 10
|
563 |
+
|
564 |
+
if 'Chatbot AI' in cat:
|
565 |
+
index = cat.index('Chatbot AI')
|
566 |
+
cat[index] = 105
|
567 |
+
if 'Omnichannel AI' in cat:
|
568 |
+
index = cat.index('Omnichannel AI')
|
569 |
+
cat[index] = 71
|
570 |
+
if 'Whatsapp AI' in cat:
|
571 |
+
index = cat.index('Whatsapp AI')
|
572 |
+
cat[index] = 106
|
573 |
+
if 'Artificial Intelligence' in cat:
|
574 |
+
index = cat.index('Artificial Intelligence')
|
575 |
+
cat[index] = 75
|
576 |
+
|
577 |
with open('image_data.txt', 'rb') as file:
|
578 |
file_content = file.read()
|
579 |
|
|
|
603 |
"content":kontent,
|
604 |
"featured_media" : media,
|
605 |
"status": metode,
|
606 |
+
"categories": cat,
|
607 |
+
"tags":tag
|
608 |
}
|
609 |
|
610 |
response_post = requests.post(endpoint, headers=headers, data=data)
|
|
|
699 |
endpoint_media= gr.Textbox(placeholder="Masukkan Endpoint Media Wordpress", label="Endpoint Media")
|
700 |
username= gr.Textbox(placeholder="Masukkan Username Wordpress",label="Username")
|
701 |
password= gr.Textbox(placeholder="Masukkan Password Wordpress",type="password" ,label="Password")
|
702 |
+
categories = gr.Dropdown(["Artificial Intelligence", "Chatbot AI", "Whatsapp AI", "Omnichannel AI"], label="Category", info="Pilih Kategori yang Diinginkan")
|
703 |
+
tags = gr.CheckboxGroup(["ai","chatbot"], label="Tags", info="Pilih Tags yang Diinginkan")
|
704 |
metode= gr.Radio(["publish", "draft"], label="Post Status", info="Pilih Metode Publish atau Draft Untuk Memposting")
|
705 |
button_post = gr.Button("Post Article")
|
706 |
status = gr.Textbox("", label="Response")
|