"Authorization":"Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VySWQiOiJsaTE3NzE5MzMzNzAyQGdtYWlsLmNvbSIsImV4cGlyZSI6MTcwMzU0ODgwMDAwMCwicmFuZG9tIjoiYTExNTUyZWUyMWU4MTFhOTFiZGFmZTUwMWE0YTA0MDgifQ==.gOnk9jo6LidZSRB/kip94HfwvLCiPUSuL2pbCk+pUzg=",# Replace with your actual token
# Function to check task status and display the image when it's ready
defcheck_and_display_status(task_id):
url_task="https://midjourney.chatgot.io/task"
headers={
"Authorization":"Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VySWQiOiJsaTE3NzE5MzMzNzAyQGdtYWlsLmNvbSIsImV4cGlyZSI6MTcwMzU0ODgwMDAwMCwicmFuZG9tIjoiYTExNTUyZWUyMWU4MTFhOTFiZGFmZTUwMWE0YTA0MDgifQ==.gOnk9jo6LidZSRB/kip94HfwvLCiPUSuL2pbCk+pUzg=",# Replace with your actual token
"Content-Type":"application/json"
}
ifmenu==menu1:
st.subheader(f"{menu1}")
task_status='pending'
withst.spinner('Waiting for image to be processed...'):
whiletask_status!='finished':
task_info=check_task(task_id,url_task,headers)
task_status=task_info['data']['status']
iftask_status=='finished':
image_url=task_info['data']['image_url']
st.success(f"Task completed: Image is available at {image_url}")
st.image(image_url)
break
else:
time.sleep(10)# This delay prevents spamming the API with requests