mirror of
https://github.com/Kakune55/PyGetGPT.git
synced 2025-12-14 08:13:55 +08:00
完成后台管理页面-列出密钥与删除功能
This commit is contained in:
27
main.py
27
main.py
@@ -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"])
|
||||
Reference in New Issue
Block a user