modified: app.py
new file: templates/index.html
This commit is contained in:
39
app.py
39
app.py
@@ -1,3 +1,36 @@
|
||||
@app.route("/post_form", methods=["GET"])
|
||||
def post_form():
|
||||
return render_template("post.html")
|
||||
from flask import Flask, render_template, request, jsonify, redirect, url_for
|
||||
import os
|
||||
|
||||
app = Flask(__name__)
|
||||
|
||||
# Beispiel-Datenstruktur für gespeicherte Webhooks
|
||||
webhooks = []
|
||||
|
||||
@app.route("/")
|
||||
def index():
|
||||
return render_template("index.html", webhooks=webhooks)
|
||||
|
||||
@app.route("/add_webhook", methods=["POST"])
|
||||
def add_webhook():
|
||||
url = request.form.get("url")
|
||||
event = request.form.get("event")
|
||||
webhooks.append({"url": url, "event": event})
|
||||
return redirect(url_for("index"))
|
||||
|
||||
@app.route("/remove_webhook", methods=["POST"])
|
||||
def remove_webhook():
|
||||
url = request.form.get("url")
|
||||
webhooks[:] = [hook for hook in webhooks if hook["url"] != url]
|
||||
return redirect(url_for("index"))
|
||||
|
||||
@app.route("/post_message", methods=["POST"])
|
||||
def post_message():
|
||||
category = request.form.get("category")
|
||||
message = request.form.get("message")
|
||||
bot.loop.create_task(post_manual(category, message))
|
||||
return jsonify({"status": "success"}), 200
|
||||
|
||||
# Weitere Routen und Logik...
|
||||
|
||||
if __name__ == "__main__":
|
||||
app.run(host="0.0.0.0", port=5000)
|
||||
|
||||
57
templates/index.html
Normal file
57
templates/index.html
Normal file
@@ -0,0 +1,57 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>Info-Bot Admin Panel</title>
|
||||
<link href="https://stackpath.bootstrapcdn.com/bootstrap/4.5.2/css/bootstrap.min.css" rel="stylesheet">
|
||||
</head>
|
||||
<body>
|
||||
<div class="container mt-5">
|
||||
<h1 class="text-center">Info-Bot Admin Panel</h1>
|
||||
|
||||
<h2>Add Webhook</h2>
|
||||
<form action="/add_webhook" method="post">
|
||||
<div class="form-group">
|
||||
<label for="url">Webhook URL:</label>
|
||||
<input type="url" class="form-control" id="url" name="url" required>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="event">Event:</label>
|
||||
<input type="text" class="form-control" id="event" name="event" required>
|
||||
</div>
|
||||
<button type="submit" class="btn btn-primary">Add Webhook</button>
|
||||
</form>
|
||||
|
||||
<h2 class="mt-4">Current Webhooks</h2>
|
||||
<ul class="list-group">
|
||||
{% for webhook in webhooks %}
|
||||
<li class="list-group-item">
|
||||
{{ webhook.url }} - {{ webhook.event }}
|
||||
<form action="/remove_webhook" method="post" style="display: inline;">
|
||||
<input type="hidden" name="url" value="{{ webhook.url }}">
|
||||
<button type="submit" class="btn btn-danger btn-sm">Remove</button>
|
||||
</form>
|
||||
</li>
|
||||
{% endfor %}
|
||||
</ul>
|
||||
|
||||
<h2 class="mt-4">Post a Message</h2>
|
||||
<form action="/post_message" method="post">
|
||||
<div class="form-group">
|
||||
<label for="category">Category:</label>
|
||||
<select class="form-control" id="category" name="category">
|
||||
<option value="Important">Important</option>
|
||||
<option value="Info">Info</option>
|
||||
<option value="Update">Update</option>
|
||||
</select>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="message">Message:</label>
|
||||
<textarea class="form-control" id="message" name="message" rows="3" required></textarea>
|
||||
</div>
|
||||
<button type="submit" class="btn btn-success">Post Message</button>
|
||||
</form>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
Reference in New Issue
Block a user