amirgame197's picture
Create app.py
d61f523 verified
raw
history blame
609 Bytes
import gradio as gr
import requests
import random
import sys
import os
def download(url):
filename = str(random.randint(111111111, 999999999)) + ".png"
file_path = os.path.join(os.path.dirname(__file__), filename)
response = requests.get(url)
if response.status_code == 200:
with open(file_path, "wb") as f:
f.write(response.content)
return(file_path)
def process(prompt):
download_file("https://image.pollinations.ai/prompt/" + text + ('.' * random.randint(0, 100)))
iface = gr.Interface(fn=process, inputs="text", outputs="image")
iface.launch()