testapi / app.py
Taf2023's picture
Update app.py
9feeb34 verified
raw
history blame contribute delete
779 Bytes
import random
import gradio as gr
import subprocess
def randomize_words():
words = ['apple', 'banana', 'orange', 'grape', 'pear']
random.shuffle(words)
randomized_words = ' '.join(words)
return randomized_words
iface = gr.Interface(fn=randomize_words,
inputs=None,
outputs="text",
title='Random Word API',
description='Click "Generate" to get a random order of words.')
# Launch the Gradio interface
iface.launch(share=False)
# Set up Ngrok tunnel to create a public URL
ngrok_process = subprocess.Popen(['ngrok', 'http', '7860'])
# Display the Ngrok tunnel URL in the output
ngrok_url = "Ngrok tunnel URL: https://dashboard.ngrok.com/status/tunnels"
print(ngrok_url)