import gradio as gr import subprocess import threading logs = "" def run_bot(): global logs process = subprocess.Popen( ["python3", "bot.py"], stdout=subprocess.PIPE, stderr=subprocess.STDOUT, text=True, bufsize=1 ) for line in process.stdout: logs += line # Start the bot in a background thread threading.Thread(target=run_bot, daemon=True).start() def launch_bot(): return "✅ Bot launched successfully." def get_logs(): return logs[-2000:] with gr.Blocks() as demo: gr.Markdown("# 🎬 TheMovieProviderBot Interface") gr.Markdown("Interact with the bot on Telegram.") gr.Markdown("[📦 Click here to download bot files](static/setup.zip)") with gr.Row(): launch_btn = gr.Button("🚀 Start Bot") refresh_btn = gr.Button("🔁 Refresh Logs") log_output = gr.Textbox(label="📄 Bot Logs", lines=20) launch_btn.click(fn=launch_bot, outputs=None) refresh_btn.click(fn=get_logs, outputs=log_output) demo.launch()