diff --git a/z2/web_app.py b/z2/web_app.py deleted file mode 100644 index 7a26a10..0000000 --- a/z2/web_app.py +++ /dev/null @@ -1,141 +0,0 @@ -from flask import Flask, render_template_string, jsonify -import mysql.connector - -app = Flask(__name__) - -DB_CONFIG = { - "host": "mysql", - "user": "root", - "password": "0674998280tanya", - "database": "telegram_bot" -} - -TEMPLATE = """ - - - - - Zoznam porušovateľov - - - -
-

Zoznam porušovateľov

- - - - - - {% for row in data %} - - {% endfor %} - -
PoužívateľSpráva
{{ row[0] }}{{ row[1] }}
-
- - - - -""" - -@app.route('/') -def index(): - conn = mysql.connector.connect(**DB_CONFIG) - cursor = conn.cursor() - cursor.execute("SELECT username, message FROM violators ORDER BY id DESC") - data = cursor.fetchall() - cursor.close() - conn.close() - return render_template_string(TEMPLATE, data=data) - -@app.route('/data') -def data(): - conn = mysql.connector.connect(**DB_CONFIG) - cursor = conn.cursor() - cursor.execute("SELECT username, message FROM violators ORDER BY id DESC") - data = cursor.fetchall() - cursor.close() - conn.close() - return jsonify(data) - -if __name__ == "__main__": - app.run(host='0.0.0.0', port=5000) \ No newline at end of file