1
0
Fork 0
forked from bton/matekasse

base.html without html and base

This commit is contained in:
2000-Trek 2023-06-23 23:24:14 +02:00
parent ac1cb4aab4
commit 6a9fbb6a8a

17
main.py
View file

@ -61,9 +61,8 @@ def list():
text = "" text = ""
for i in users: for i in users:
text = text + f'<p><a href="list/user?id={i[0]}">{escape(i[1])}</a>: {i[2]} <form action="/change" method="get"><input name="id" type="hidden" value="{i[0]}"> Change balance: <input name="change"><input type="submit"></form></p> <br style="line-height: 50%;"></br>' text = text + f'<p><a href="list/user?id={i[0]}">{escape(i[1])}</a>: {i[2]} <form action="/change" method="get"><input name="id" type="hidden" value="{i[0]}"> Change balance: <input name="change"><input type="submit"></form></p> <br style="line-height: 50%;"></br>'
return ''' return '''<!DOCTYPE html>
{% extends 'base.html' %} <html lang="en">
{% block content %}
<script src="https://cdnjs.cloudflare.com/ajax/libs/socket.io/4.0.1/socket.io.js" integrity="sha512-q/dWJ3kcmjBLU4Qc47E4A9kTB4m3wuTY7vkFJDTZKjTs8jhyGQnaUrxa0Ytd0ssMZhbNua9hE+E7Qv1j+DyZwA==" crossorigin="anonymous"></script> <script src="https://cdnjs.cloudflare.com/ajax/libs/socket.io/4.0.1/socket.io.js" integrity="sha512-q/dWJ3kcmjBLU4Qc47E4A9kTB4m3wuTY7vkFJDTZKjTs8jhyGQnaUrxa0Ytd0ssMZhbNua9hE+E7Qv1j+DyZwA==" crossorigin="anonymous"></script>
<script type="text/javascript" charset="utf-8"> <script type="text/javascript" charset="utf-8">
var socket = io(); var socket = io();
@ -71,11 +70,12 @@ def list():
window.location="http://matekasse.server.c3h/list" window.location="http://matekasse.server.c3h/list"
}); });
</script> </script>
<p><a href="/list">user and tag list</a> | <a href="/documentation">Documentation</a></p>
<p>1 Credit = 1,50 Euro</p> <p>1 Credit = 1,50 Euro</p>
<form action="/list/user" method="get"> Search for User: <input name="user"><input type="submit"></form> <form action="/list/user" method="get"> Search for User: <input name="user"><input type="submit"></form>
<form action="/adduser" method="get"><button type="submit">Add User</button></form> <form action="/adduser" method="get"><button type="submit">Add User</button></form>
<br></br> <br></br>
''' + text + '<a href="/documentation">Doumentation</a> {% block content %}' ''' + text + '<a href="/documentation">Doumentation</a></html>'
@app.route("/list/user", methods=['GET']) @app.route("/list/user", methods=['GET'])
def user_info(): def user_info():
@ -96,6 +96,7 @@ def user_info():
var socket = io(); var socket = io();
""" + 'socket.on("update", function(){ window.location="http://matekasse.server.c3h/list/user?id=' + id + '"});' + f""" """ + 'socket.on("update", function(){ window.location="http://matekasse.server.c3h/list/user?id=' + id + '"});' + f"""
</script> </script>
<p><a href="/list">user and tag list</a> | <a href="/documentation">Documentation</a></p>
<p> {escape(user[1])} : {user[2]} <p> <p> {escape(user[1])} : {user[2]} <p>
<form action="/addtag" method="get"><input name="id" type="hidden" value="{user[0]}"><button type="submit">Add Tag</button></form> <form action="/addtag" method="get"><input name="id" type="hidden" value="{user[0]}"><button type="submit">Add Tag</button></form>
<form action="/removetag" method="get"><input name="id" type="hidden" value="{user[0]}"><button type="submit">Remove Tag</button></form> <form action="/removetag" method="get"><input name="id" type="hidden" value="{user[0]}"><button type="submit">Remove Tag</button></form>
@ -118,7 +119,7 @@ def new_user():
@app.route("/removeuser/confirmation", methods=['GET']) @app.route("/removeuser/confirmation", methods=['GET'])
def confirm_remove_user(): def confirm_remove_user():
user_id = request.args.get("id") user_id = request.args.get("id")
return f'Do your realy want to <a href="/removeuser?id={user_id}">remove the user</a>' return f'<p><a href="/list">user and tag list</a> | <a href="/documentation">Documentation</a></p> <p>Do your realy want to <a href="/removeuser?id={user_id}">remove the user</a></p>'
@app.route("/removeuser", methods=['GET']) @app.route("/removeuser", methods=['GET'])
def remove_user(): def remove_user():
@ -133,7 +134,7 @@ def remove_user():
db_log.info(f"Deleted user {user_id}") db_log.info(f"Deleted user {user_id}")
conn.commit() conn.commit()
socketio.emit("update", "update") socketio.emit("update", "update")
return f'<p>Deleted user {escape(user_name)}</p><a href="/list">return to the tags and user list</a>' return f'<p><p><a href="/list">user and tag list</a> | <a href="/documentation">Documentation</a></p> <p>Deleted user {escape(user_name)}</p><a href="/list">return to the tags and user list</a></p>'
else: else:
return "Error: 043" return "Error: 043"
@ -156,7 +157,7 @@ def adduser():
</html> </html>
""" """
else: else:
return '<p>Error: 170</p> <a href="/list">user and tag list</a>' return '<p><a href="/list">user and tag list</a> | <a href="/documentation">Documentation</a></p><p>Error: 170</p> '
@app.route("/change", methods=['GET']) @app.route("/change", methods=['GET'])
@ -184,7 +185,7 @@ def change():
</html> </html>
""" """
else: else:
return "Error: 043" return '<p><a href="/list">user and tag list</a> | <a href="/documentation">Documentation</a></p> <p>Error: 043</p>'
@app.route("/addtag", methods=['GET']) @app.route("/addtag", methods=['GET'])
def get_addtag_request(): def get_addtag_request():