Exemplo n.º 1
0
def Login():
    username = request.form.get('username')
    password =  request.form.get('password')
    if request.method == 'GET':
        return render_template('login.html')
    if user.vilidate_login(username,password):
        session['user'] = {'username':username}
        # 跳转到首页
        return redirect('/user/list/')
    else:
        return render_template('login.html',username=username,error=u'用户名或密码错误!')
Exemplo n.º 2
0
def asset_command():
    perams = request.args if request.method == 'GET' else request.form
    asset_ip = perams.get('ip')
    _mpasswd = perams.get('mpassword')
    print session['user']['username']
    if request.method == 'GET':
        info = u'这里是返回的结果信息'
        return render_template('/asset/asset_command.html',
                               ip=asset_ip,
                               info=info)
    else:
        _status = user.vilidate_login(session['user']['username'], _mpasswd)
        info = []
        if _status:
            cmd_list = perams.get('command', '').split(';')
            ssh = Ssh(host='127.0.0.1', cmds=cmd_list)
            _rt_list = ssh.ssh_execute()
            for cmd, out, err in _rt_list:
                info.append([out, err])
        return json.dumps({'status': _status, 'info': info})