Spaces:
Paused
Paused
Update app.py
Browse files
app.py
CHANGED
|
@@ -470,15 +470,19 @@ def scrap(link_scrap,backlink,keyword,openai_key,replicate_key):
|
|
| 470 |
def post(judul, kontent, endpoint,endpoint_media,username,password,tags,categories,metode):
|
| 471 |
credentials = base64.b64encode(f"{username}:{password}".encode("utf-8")).decode("utf-8")
|
| 472 |
headers = {"Authorization": f"Basic {credentials}"}
|
| 473 |
-
|
| 474 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 475 |
|
| 476 |
data = {
|
| 477 |
"alt_text": judul,
|
| 478 |
"media_type": "image",
|
| 479 |
"mime_type": "png"
|
| 480 |
}
|
| 481 |
-
files = {"file": ("image.jpg",
|
| 482 |
try :
|
| 483 |
response_media= requests.post(endpoint_media, headers=headers, data=data, files=files) # Send
|
| 484 |
|
|
|
|
| 470 |
def post(judul, kontent, endpoint,endpoint_media,username,password,tags,categories,metode):
|
| 471 |
credentials = base64.b64encode(f"{username}:{password}".encode("utf-8")).decode("utf-8")
|
| 472 |
headers = {"Authorization": f"Basic {credentials}"}
|
| 473 |
+
|
| 474 |
+
file_path = 'image_data.txt'
|
| 475 |
+
|
| 476 |
+
try:
|
| 477 |
+
with open(file_path, 'r') as file:
|
| 478 |
+
image = file.read()
|
| 479 |
|
| 480 |
data = {
|
| 481 |
"alt_text": judul,
|
| 482 |
"media_type": "image",
|
| 483 |
"mime_type": "png"
|
| 484 |
}
|
| 485 |
+
files = {"file": ("image.jpg", image)}
|
| 486 |
try :
|
| 487 |
response_media= requests.post(endpoint_media, headers=headers, data=data, files=files) # Send
|
| 488 |
|