webuiの実装はじめ
This commit is contained in:
parent
49a182b62b
commit
783b4eb385
4 changed files with 95 additions and 2 deletions
|
@ -1,7 +1,7 @@
|
|||
import psycopg2
|
||||
import os
|
||||
import json
|
||||
from flask import Flask, request, jsonify, render_template
|
||||
from flask import Flask, request, jsonify, render_template, redirect
|
||||
import uuid
|
||||
import string
|
||||
import random
|
||||
|
@ -337,7 +337,12 @@ class Auth():
|
|||
|
||||
finally:
|
||||
cursor.close()
|
||||
|
||||
|
||||
def get_pc_list(self, **kwargs):
|
||||
cursor = self.db.cursor()
|
||||
cursor.execute('SELECT pc_number, alt_name, master_password FROM pc_list ORDER BY pc_number')
|
||||
pc_list = cursor.fetchall()
|
||||
return pc_list
|
||||
|
||||
app = Flask(__name__, static_folder="./resource/")
|
||||
auth = Auth(server_config["db"]["host"], server_config["db"]["db_name"], server_config["db"]["port"], server_config["db"]["username"], server_config["db"]["password"])
|
||||
|
@ -479,6 +484,33 @@ def device_register():
|
|||
else:
|
||||
return jsonify({'message': 'damedesu'}), 401
|
||||
|
||||
@app.route('/')
|
||||
def index():
|
||||
return redirect('/admin')
|
||||
|
||||
@app.route('/admin')
|
||||
def admin():
|
||||
return render_template('admin.html')
|
||||
|
||||
@app.route('/admin/pc_list')
|
||||
def admin_pclist():
|
||||
table = '<table><thead><tr><th>PC番号</th><th>ニックネーム</th><th>マスターパスワード</th></tr></thead><tbody>'
|
||||
pc_list = auth.get_pc_list()
|
||||
for i in pc_list:
|
||||
pc_number = i[0]
|
||||
alt_name = i[1]
|
||||
if alt_name == None:
|
||||
alt_name = '--未登録--'
|
||||
|
||||
master_password = i[2]
|
||||
if master_password == None:
|
||||
master_password = '--未登録--'
|
||||
|
||||
table += f'<tr><td>{pc_number}</td><td>{alt_name}</td><td>{master_password}</td></tr>'
|
||||
|
||||
table += '</tbody></table>'
|
||||
|
||||
return render_template('pc_list.html', pc_list_table=table)
|
||||
|
||||
if __name__ == '__main__':
|
||||
app.run(host="0.0.0.0", port=5000, debug=False)
|
13
resource/css/admin.css
Normal file
13
resource/css/admin.css
Normal file
|
@ -0,0 +1,13 @@
|
|||
#sidebar {
|
||||
|
||||
height: 100%;
|
||||
width: 30%;
|
||||
background-color: aliceblue;
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
}
|
||||
|
||||
#general {
|
||||
display: flex;
|
||||
float: left;
|
||||
}
|
24
templates/admin.html
Normal file
24
templates/admin.html
Normal file
|
@ -0,0 +1,24 @@
|
|||
<html>
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<title>Dislocker Admin</title>
|
||||
<link rel="stylesheet" href="{{url_for('static', filename='/css/admin.css')}}">
|
||||
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<div id="general">
|
||||
<div id="sidebar">
|
||||
<button onclick="location.href='/admin'" type="button" style="height: auto;" >
|
||||
<img src="{{url_for('static', filename='/icon/png/64.png')}}" alt="Home" style="width: 64px; height: 64px;">
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<div id="main">
|
||||
<h1>Dislocker ADMIN</h1>
|
||||
<button onclick="location.href='/admin/pc_list'">PCリスト</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</body>
|
||||
</html>
|
24
templates/pc_list.html
Normal file
24
templates/pc_list.html
Normal file
|
@ -0,0 +1,24 @@
|
|||
<html>
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<title>Dislocker Admin | PC List</title>
|
||||
<link rel="stylesheet" href="{{url_for('static', filename='/css/admin.css')}}">
|
||||
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<div id="general">
|
||||
<div id="sidebar">
|
||||
<button onclick="location.href='/admin'" type="button" style="height: auto;">
|
||||
<img src="{{url_for('static', filename='/icon/png/64.png')}}" alt="Home" style="width: 64px; height: 64px;">
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<div id="main">
|
||||
<h1>PCリストあるよ(笑)</h1>
|
||||
{{pc_list_table | safe}}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</body>
|
||||
</html>
|
Loading…
Reference in a new issue