helal-muneer
commited on
Commit
•
5c3eb22
1
Parent(s):
6e003ec
using ngrok and flask
Browse files
app.py
CHANGED
@@ -1,3 +1,31 @@
|
|
|
|
1 |
import gradio as gr
|
|
|
|
|
2 |
|
3 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
from flask import Flask
|
2 |
import gradio as gr
|
3 |
+
import threading
|
4 |
+
from pyngrok import ngrok
|
5 |
|
6 |
+
app = Flask(__name__)
|
7 |
+
|
8 |
+
@app.route("/")
|
9 |
+
def gradio_app():
|
10 |
+
gr.load("models/Salama1429/tarteel-ai-whisper-base-ar-quran").launch(share=True)
|
11 |
+
return "Gradio app launched"
|
12 |
+
|
13 |
+
def run_flask():
|
14 |
+
app.run(host='0.0.0.0', port=5000)
|
15 |
+
|
16 |
+
if __name__ == "__main__":
|
17 |
+
# Start ngrok when the app is run
|
18 |
+
ngrok_tunnel = ngrok.connect(5000)
|
19 |
+
print("Public URL:", ngrok_tunnel.public_url)
|
20 |
+
|
21 |
+
# Start Flask in a separate thread
|
22 |
+
flask_thread = threading.Thread(target=run_flask)
|
23 |
+
flask_thread.start()
|
24 |
+
|
25 |
+
# Keep the main thread alive
|
26 |
+
try:
|
27 |
+
input("Press Enter to quit...\n")
|
28 |
+
finally:
|
29 |
+
# Stop ngrok and Flask
|
30 |
+
ngrok.kill()
|
31 |
+
flask_thread.join()
|