From fc3ba617af0a5ea3d17e5dd07656350a2a5abf66 Mon Sep 17 00:00:00 2001 From: daniel Date: Mon, 20 Apr 2020 20:52:31 +0800 Subject: [PATCH] =?UTF-8?q?=E5=8A=A8=E6=80=81=E8=B7=AF=E7=94=B1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- server/jumpserver.py | 76 ++++++++++++++++---------------------------- 1 file changed, 28 insertions(+), 48 deletions(-) diff --git a/server/jumpserver.py b/server/jumpserver.py index aea1472..58f58a8 100644 --- a/server/jumpserver.py +++ b/server/jumpserver.py @@ -258,54 +258,34 @@ def userlist(): return do_userlist(request) -@app.route('/jump/user/add', methods=['GET', 'POST']) -def add_user(): - return do_add_user(request) - - -@app.route('/jump/user/del', methods=['GET', 'POST']) -def del_user(): - return do_del_user(request) - - -@app.route('/jump/user/modify', methods=['GET', 'POST']) -def modify_user(): - return do_modify_user(request) - - -@app.route('/jump/user/hosts', methods=['GET', 'POST']) -def userhostlist(): - return do_userhostlist(request) - - -@app.route('/jump/host/add', methods=['GET', 'POST']) -def add_host(): - return do_add_host(request) - - -@app.route('/jump/host/del', methods=['GET', 'POST']) -def del_host(): - return do_del_host(request) - - -@app.route('/jump/host/adduser', methods=['GET', 'POST']) -def host_adduser(): - return do_host_adduser(request) - - -@app.route('/jump/host/deluser', methods=['GET', 'POST']) -def host_deluser(): - return do_host_deluser(request) - - -@app.route('/jump/host/modifyuser', methods=['GET', 'POST']) -def host_modifyuser(): - return do_host_modifyuser(request) - - -@app.route('/jump/host/users', methods=['GET', 'POST']) -def hostuserlist(): - return do_hostuserlist(request) +# user动态路由 +@app.route('/jump/user/', methods=['GET', 'POST']) +def user_op(op): + if op == "add": + return do_add_user(request) + elif op == "del": + return do_del_user(request) + elif op == "modify": + return do_modify_user(request) + elif op == "hosts": + return do_userhostlist(request) + + +# host动态路由 +@app.route('/jump/host/', methods=['GET', 'POST']) +def host_op(op): + if op == "add": + return do_add_host(request) + elif op == "del": + return do_del_host(request) + elif op == "adduser": + return do_host_adduser(request) + elif op == "deluser": + return do_host_deluser(request) + elif op == "modifyuser": + return do_host_modifyuser(request) + elif op == "users": + return do_hostuserlist(request) @app.route('/jump/hostuser', methods=['GET', 'POST'])