完成后台管理页面-列出密钥与删除功能

This commit is contained in:
2023-12-11 10:55:44 +08:00
parent 3157ccd3a9
commit bfef66d293
5 changed files with 254 additions and 72 deletions

27
main.py
View File

@@ -70,9 +70,34 @@ def login():
@app.route('/admin')
def admin():
if "admin" in flask.session :
return "管理页"
status = {}
status["db"] = db.dbIsOK()
return flask.render_template("status.html" ,status=status)
return "未登录"
@app.route('/admin/list')
def adminList():
if "admin" in flask.session :
data = db.getAllKey()
return flask.render_template("keylist.html",data=data)
return "未登录 "
@app.route('/admin/createkey')
def createkey():
if "admin" in flask.session :
return flask.render_template("createKey.html")
return "未登录 "
@app.route('/admin/operate', methods=['POST','GET'])
def operate():
if "admin" in flask.session :
if flask.request.args['type'] == "del":
if db.delKey(flask.request.args['target']):
return "成功 <a href='javascript:;' onclick='self.location=document.referrer;'>返回上一页并刷新</a>"
return "失败 <a href='javascript:;' onclick='self.location=document.referrer;'>返回上一页并刷新</a>"
return "拒绝访问"
if __name__ == '__main__':
app.run(debug=bool(config.readConf()["appconf"]["debug"]),host=config.readConf()["appconf"]["host"],port=config.readConf()["appconf"]["port"])