file / app.py
Kanhshsh's picture
Update app.py
69a921f verified
raw
history blame
1.04 kB
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()