Spaces:
Running
Running
File size: 1,237 Bytes
c01079c 399ebd7 c01079c 399ebd7 c01079c 399ebd7 c01079c 399ebd7 c01079c d27b456 c01079c 399ebd7 c01079c |
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 streamlit as st
import subprocess
import sys
# Set up the page configuration
st.set_page_config(page_title="Gojo Satoru Telegram Bot", layout="centered")
st.title("Gojo Satoru Telegram Bot")
# Install required packages from requirements.txt
st.markdown("### Installing requirements from `requirements.txt`...")
with st.spinner("Installing dependencies..."):
try:
subprocess.check_call([sys.executable, "-m", "pip", "install", "-r", "requirements.txt"])
st.success("Requirements installed successfully.")
except subprocess.CalledProcessError as e:
st.error(f"Failed to install requirements: {e}")
st.stop() # Stop further execution if installation fails
# Run the bot using python3 -m powers
st.markdown("### Running `python3 -m powers`...")
with st.spinner("Launching bot..."):
try:
result = subprocess.run(
[sys.executable, "-m", "Powers"], # Running python3 -m powers
stdout=subprocess.PIPE,
stderr=subprocess.PIPE,
text=True
)
# Display bot logs (stdout and stderr)
st.code(result.stdout + result.stderr, language='bash')
except Exception as e:
st.error(f"Failed to start the bot: {e}") |