Dragdev commited on
Commit
5652266
·
verified ·
1 Parent(s): 6ea8d13

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +12 -28
app.py CHANGED
@@ -1,32 +1,16 @@
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}")
 
1
+ import os
2
  import subprocess
3
+ import streamlit as st
4
+
5
+ # Set up the environment (if needed)
6
+ os.environ["PYTHONUNBUFFERED"] = "1"
7
 
8
+ # Run the Gojo_Satoru bot from Powers module
9
+ def run_bot():
10
+ subprocess.run(["python3", "-m", "Powers"])
11
 
12
+ st.title("Telegram Bot")
 
 
 
 
 
 
 
 
13
 
14
+ if st.button("Start flash Bot"):
15
+ run_bot()
16
+ st.success("flash Bot is running!")