modified: app.py
modified: requirements.txt
This commit is contained in:
22
app.py
22
app.py
@@ -1,24 +1,29 @@
|
|||||||
# app.py
|
# web_panel/app.py
|
||||||
|
|
||||||
from flask import Flask, render_template, redirect, url_for, request, session
|
from flask import Flask, render_template, redirect, url_for, request, session
|
||||||
import os
|
import os
|
||||||
import subprocess
|
import subprocess
|
||||||
|
import psutil
|
||||||
|
|
||||||
app = Flask(__name__)
|
app = Flask(__name__)
|
||||||
app.secret_key = os.getenv("FLASK_SECRET_KEY", "default_secret_key")
|
app.secret_key = os.getenv("FLASK_SECRET_KEY", "default_secret_key")
|
||||||
|
|
||||||
# Status-Anzeige des Bots
|
|
||||||
def bot_status():
|
def bot_status():
|
||||||
result = subprocess.run(["pgrep", "-f", "bot.py"], stdout=subprocess.PIPE)
|
"""Überprüft, ob der Bot läuft."""
|
||||||
return result.returncode == 0 # 0 bedeutet, dass der Prozess läuft
|
for proc in psutil.process_iter(['pid', 'name', 'cmdline']):
|
||||||
|
if 'python' in proc.info['name'] and 'bot.py' in proc.info['cmdline']:
|
||||||
|
return True
|
||||||
|
return False
|
||||||
|
|
||||||
# Startet den Bot
|
|
||||||
def start_bot():
|
def start_bot():
|
||||||
|
"""Startet den Bot."""
|
||||||
subprocess.Popen(["python", "bot.py"], cwd=os.path.dirname(os.path.abspath(__file__)))
|
subprocess.Popen(["python", "bot.py"], cwd=os.path.dirname(os.path.abspath(__file__)))
|
||||||
|
|
||||||
# Stoppt den Bot
|
|
||||||
def stop_bot():
|
def stop_bot():
|
||||||
subprocess.run(["pkill", "-f", "bot.py"])
|
"""Stoppt den Bot."""
|
||||||
|
for proc in psutil.process_iter(['pid', 'name', 'cmdline']):
|
||||||
|
if 'python' in proc.info['name'] and 'bot.py' in proc.info['cmdline']:
|
||||||
|
proc.terminate()
|
||||||
|
break
|
||||||
|
|
||||||
@app.route("/")
|
@app.route("/")
|
||||||
def index():
|
def index():
|
||||||
@@ -62,7 +67,6 @@ def settings():
|
|||||||
if "username" in session:
|
if "username" in session:
|
||||||
if request.method == "POST":
|
if request.method == "POST":
|
||||||
# Hier kannst du Formulareingaben für Bot-Einstellungen verarbeiten
|
# Hier kannst du Formulareingaben für Bot-Einstellungen verarbeiten
|
||||||
# Z.B. in die .env-Datei schreiben
|
|
||||||
pass
|
pass
|
||||||
return render_template("settings.html")
|
return render_template("settings.html")
|
||||||
return redirect(url_for("login"))
|
return redirect(url_for("login"))
|
||||||
|
|||||||
@@ -11,4 +11,5 @@ youtube_dl
|
|||||||
beautifulsoup4
|
beautifulsoup4
|
||||||
pdfplumber
|
pdfplumber
|
||||||
python-dotenv
|
python-dotenv
|
||||||
flask
|
flask
|
||||||
|
psutil
|
||||||
Reference in New Issue
Block a user