modified: app.py
modified: templates/settings.html
This commit is contained in:
33
app.py
33
app.py
@@ -6,6 +6,10 @@ import psutil
|
||||
app = Flask(__name__)
|
||||
app.secret_key = os.getenv("FLASK_SECRET_KEY", "default_secret_key")
|
||||
|
||||
# Globale Variablen für die Intros
|
||||
INTRO_FILE = "introduction.txt"
|
||||
ASKNOTES_INTRO_FILE = "asknotesintro.txt"
|
||||
|
||||
# Speichern der Prozess-ID
|
||||
bot_process = None
|
||||
|
||||
@@ -34,6 +38,18 @@ def stop_bot():
|
||||
else:
|
||||
print("Bot läuft nicht.")
|
||||
|
||||
def load_text_file(file_path):
|
||||
"""Lädt den Inhalt einer Textdatei."""
|
||||
if os.path.exists(file_path):
|
||||
with open(file_path, 'r', encoding='utf-8') as file:
|
||||
return file.read()
|
||||
return ""
|
||||
|
||||
def save_text_file(file_path, content):
|
||||
"""Speichert den Inhalt in einer Textdatei."""
|
||||
with open(file_path, 'w', encoding='utf-8') as file:
|
||||
file.write(content)
|
||||
|
||||
@app.route("/")
|
||||
def index():
|
||||
if "username" in session:
|
||||
@@ -75,9 +91,20 @@ def stop():
|
||||
def settings():
|
||||
if "username" in session:
|
||||
if request.method == "POST":
|
||||
# Hier kannst du Formulareingaben für Bot-Einstellungen verarbeiten
|
||||
pass
|
||||
return render_template("settings.html")
|
||||
introduction = request.form.get("introduction")
|
||||
asknotes_introduction = request.form.get("asknotes_introduction")
|
||||
|
||||
# Speichern der Intros
|
||||
save_text_file(INTRO_FILE, introduction)
|
||||
save_text_file(ASKNOTES_INTRO_FILE, asknotes_introduction)
|
||||
|
||||
return redirect(url_for("settings"))
|
||||
|
||||
# Laden der aktuellen Inhalte aus den Textdateien
|
||||
introduction = load_text_file(INTRO_FILE)
|
||||
asknotes_introduction = load_text_file(ASKNOTES_INTRO_FILE)
|
||||
|
||||
return render_template("settings.html", introduction=introduction, asknotes_introduction=asknotes_introduction)
|
||||
return redirect(url_for("login"))
|
||||
|
||||
if __name__ == "__main__":
|
||||
|
||||
Reference in New Issue
Block a user