helal-muneer's picture
using ngrok and flask
5c3eb22 verified
raw
history blame contribute delete
772 Bytes
from flask import Flask
import gradio as gr
import threading
from pyngrok import ngrok
app = Flask(__name__)
@app.route("/")
def gradio_app():
gr.load("models/Salama1429/tarteel-ai-whisper-base-ar-quran").launch(share=True)
return "Gradio app launched"
def run_flask():
app.run(host='0.0.0.0', port=5000)
if __name__ == "__main__":
# Start ngrok when the app is run
ngrok_tunnel = ngrok.connect(5000)
print("Public URL:", ngrok_tunnel.public_url)
# Start Flask in a separate thread
flask_thread = threading.Thread(target=run_flask)
flask_thread.start()
# Keep the main thread alive
try:
input("Press Enter to quit...\n")
finally:
# Stop ngrok and Flask
ngrok.kill()
flask_thread.join()