add admin panel
This commit is contained in:
parent
ea3c737c04
commit
a5d02f3efd
5 changed files with 49 additions and 3 deletions
12
main.py
12
main.py
|
@ -1,4 +1,5 @@
|
|||
from flask import Flask, request, make_response, render_template
|
||||
from flask_basicauth import BasicAuth
|
||||
from dotenv import load_dotenv
|
||||
from flask_sock import Sock
|
||||
from glob import glob
|
||||
|
@ -9,6 +10,10 @@ import os
|
|||
load_dotenv()
|
||||
app = Flask(__name__)
|
||||
sock = Sock(app)
|
||||
basic_auth = BasicAuth(app)
|
||||
|
||||
app.config['BASIC_AUTH_USERNAME'] = os.getenv("AUTH_USERNAME")
|
||||
app.config['BASIC_AUTH_PASSWORD'] = os.getenv("AUTH_PASSWORD")
|
||||
|
||||
def make_resp(data=''):
|
||||
response = make_response(data)
|
||||
|
@ -136,6 +141,13 @@ def websocket(ws):
|
|||
if operation == "usernames": # TODO
|
||||
ws.send(json.dumps({"1": "Mathias"}))
|
||||
|
||||
@app.route("/admin")
|
||||
@basic_auth.required
|
||||
def admin_panel():
|
||||
users = database.db.execute_query("SELECT name, email FROM users;")
|
||||
vaults = database.db.execute_query("SELECT name, (SELECT name FROM users WHERE uid=owner) FROM vaults;")
|
||||
return render_template("admin.html", users=users, vaults=vaults)
|
||||
|
||||
@app.route("/")
|
||||
def index_page():
|
||||
return render_template("index.html")
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue