import queue, time, uuid, json, logging, datetime, os from flask import Flask, render_template, render_template_string, request, make_response, session, send_file, g from flask_socketio import SocketIO, join_room, leave_room from flask_session import Session from markupsafe import escape from .db import get_db from datetime import datetime finished = None preis = 1.5 #Ein Getraenk #flask_config DATABASE = './Website/mate.db' def log(type=None, userid=None, before=None, after=None): db = get_db() c = db.cursor() c.execute("INSERT or IGNORE INTO transaction_log (timestamp, userid, type, before, after) VALUES (?, ?, ?, ?, ?)", [datetime.now(), userid, type, before, after]) db.commit() def create_app(test_config=None): app = Flask(__name__) key = str(uuid.uuid4().hex) if test_config is None: app.config['SESSION_TYPE'] = 'filesystem' app.config['SECRET_KEY'] = key app.config['DATABASE'] = DATABASE else: app.config.from_mapping(test_config) try: os.makedirs(app.instance_path) except OSError: pass #with app.app_context(): # create_logs(app) Session(app) socketio = SocketIO(app) #@app.teardown_appcontext #def close_connection(exception): # db = getattr(g, '_database', None) # if db is not None: # db.close() # app.logger.info("Website exited") #var user_queue = queue.Queue() #website @app.route('/favicon.ico') def favicon(): return send_file("../static/Logo_CCC.svg.png") #@app.route('/socket.io.js') #def socketiojs(): # return url_for('static', filename='socket.io.js') @app.route("/") def index(): return render_template("index.html") @app.route("/list") def list(): db = get_db() c = db.cursor() c.execute("SELECT * FROM users") users = c.fetchall() return render_template("list.html", users=users, preis=preis) @app.route("/transactionlist") def transactionlist(): db = get_db() c = db.cursor() text = "" c.execute("SELECT * FROM transaction_log ORDER BY ROWID DESC LIMIT 100") transactionlist = c.fetchall() for i in transactionlist: text = text + f'