Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -1,30 +1,32 @@
|
|
1 |
import streamlit as st
|
2 |
import subprocess
|
3 |
import sys
|
4 |
-
import os
|
5 |
|
6 |
-
|
|
|
7 |
st.title("Gojo Satoru Telegram Bot")
|
8 |
|
9 |
-
|
10 |
-
|
|
|
11 |
try:
|
12 |
-
# Install packages
|
13 |
subprocess.check_call([sys.executable, "-m", "pip", "install", "-r", "requirements.txt"])
|
14 |
st.success("Requirements installed successfully.")
|
15 |
except subprocess.CalledProcessError as e:
|
16 |
st.error(f"Failed to install requirements: {e}")
|
17 |
-
st.stop()
|
18 |
|
19 |
-
|
|
|
20 |
with st.spinner("Launching bot..."):
|
21 |
try:
|
22 |
result = subprocess.run(
|
23 |
-
[sys.executable, "-m", "powers"],
|
24 |
stdout=subprocess.PIPE,
|
25 |
stderr=subprocess.PIPE,
|
26 |
text=True
|
27 |
)
|
|
|
28 |
st.code(result.stdout + result.stderr, language='bash')
|
29 |
except Exception as e:
|
30 |
st.error(f"Failed to start the bot: {e}")
|
|
|
1 |
import streamlit as st
|
2 |
import subprocess
|
3 |
import sys
|
|
|
4 |
|
5 |
+
# Set up the page configuration
|
6 |
+
st.set_page_config(page_title="Gojo Satoru Telegram Bot", layout="centered")
|
7 |
st.title("Gojo Satoru Telegram Bot")
|
8 |
|
9 |
+
# Install required packages from requirements.txt
|
10 |
+
st.markdown("### Installing requirements from `requirements.txt`...")
|
11 |
+
with st.spinner("Installing dependencies..."):
|
12 |
try:
|
|
|
13 |
subprocess.check_call([sys.executable, "-m", "pip", "install", "-r", "requirements.txt"])
|
14 |
st.success("Requirements installed successfully.")
|
15 |
except subprocess.CalledProcessError as e:
|
16 |
st.error(f"Failed to install requirements: {e}")
|
17 |
+
st.stop() # Stop further execution if installation fails
|
18 |
|
19 |
+
# Run the bot using python3 -m powers
|
20 |
+
st.markdown("### Running `python3 -m powers`...")
|
21 |
with st.spinner("Launching bot..."):
|
22 |
try:
|
23 |
result = subprocess.run(
|
24 |
+
[sys.executable, "-m", "powers"], # Running python3 -m powers
|
25 |
stdout=subprocess.PIPE,
|
26 |
stderr=subprocess.PIPE,
|
27 |
text=True
|
28 |
)
|
29 |
+
# Display bot logs (stdout and stderr)
|
30 |
st.code(result.stdout + result.stderr, language='bash')
|
31 |
except Exception as e:
|
32 |
st.error(f"Failed to start the bot: {e}")
|