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__":
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
<!-- web_panel/templates/settings.html -->
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
@@ -13,7 +12,14 @@
|
||||
<div class="card mt-4">
|
||||
<div class="card-body">
|
||||
<form method="POST" action="{{ url_for('settings') }}">
|
||||
<!-- Hier kannst du Formulare für Bot-Einstellungen einfügen -->
|
||||
<div class="form-group">
|
||||
<label for="introduction">Introduction Text</label>
|
||||
<textarea id="introduction" name="introduction" class="form-control" rows="5">{{ introduction }}</textarea>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="asknotes_introduction">Asknotes Introduction Text</label>
|
||||
<textarea id="asknotes_introduction" name="asknotes_introduction" class="form-control" rows="5">{{ asknotes_introduction }}</textarea>
|
||||
</div>
|
||||
<button type="submit" class="btn btn-primary btn-block">Save Settings</button>
|
||||
</form>
|
||||
<a href="{{ url_for('index') }}" class="btn btn-secondary btn-block mt-3">Back to Dashboard</a>
|
||||
|
||||
Reference in New Issue
Block a user