Dragdev commited on
Commit
399ebd7
·
verified ·
1 Parent(s): c01079c

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +10 -8
app.py CHANGED
@@ -1,30 +1,32 @@
1
  import streamlit as st
2
  import subprocess
3
  import sys
4
- import os
5
 
6
- st.set_page_config(page_title="Gojo Satoru Bot", layout="centered")
 
7
  st.title("Gojo Satoru Telegram Bot")
8
 
9
- st.markdown("### Installing requirements.txt ...")
10
- with st.spinner("Installing..."):
 
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
- st.markdown("### Running `python -m powers` ...")
 
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}")