-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathrun_app.py
32 lines (25 loc) · 1006 Bytes
/
run_app.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
import subprocess
import threading
import re
def start_tunnel():
print("Starting Cloudflare Tunnel...")
process = subprocess.Popen(['pycloudflared', 'tunnel', '--url', 'http://127.0.0.1:8501'],
stdout=subprocess.PIPE, stderr=subprocess.STDOUT, text=True)
for line in iter(process.stdout.readline, ''):
if '.trycloudflare.com' in line:
url = re.search(r'https://[a-zA-Z0-9-]+\.trycloudflare\.com', line)
if url:
print(f"Tunnel URL: {url.group()}")
break
def run_streamlit():
print("Starting Streamlit App...")
subprocess.call(['streamlit', 'run', '/kaggle/working/Ollama-Colab-Integration-Kaggle/main.py'])
def main():
tunnel_thread = threading.Thread(target=start_tunnel)
streamlit_thread = threading.Thread(target=run_streamlit)
tunnel_thread.start()
streamlit_thread.start()
tunnel_thread.join()
streamlit_thread.join()
if __name__ == "__main__":
main()