示例#1
0
文件: app.py 项目: beordle/jnu.fm
def jwc():
    args=request.args
    token = args['token']
    jwc_username = args['jwc_username']
    jwc_password = args['jwc_password']
    s=type(login(jwc_username,jwc_password))
    if not s==type('string'):
        username=getUsernameFromToken(token)
        #token不通过
        if not username:
            ret={
             'version': 1.0,
             'status': 2,
             }
            return jsonify(ret)
        user = User.query.filter_by(username=username).one()
        data = json.loads(user.json)
        data['jwc_username']=jwc_username
        data['jwc_password']=jwc_password
        user.json = json.dumps(args)
        db.session.add(user)
        db.session.commit()
        ret={
             'version': 1.0,
             'status': 0,
             }
        return jsonify(ret)
    else:
        ret={
             'version': 1.0,
             'status': 1,
             }
        return jsonify(ret)
示例#2
0
文件: app.py 项目: beordle/jnu.fm
def set_info():
    args=request.args
    token = args['token']
    username=getUsernameFromToken(token)
    #token不通过
    if not username:
            ret={
             'version': 1.0,
             'status': 2,
             }
            return jsonify(ret)

    user = User.query.filter_by(username=username).one()
    data = json.loads(user.json)

    set_data={}
    set_list=["nickname","realname","sex","signature"]
    for key,value in args.items():
        if key in set_list:
            print (key)
            set_data[key]=value
    data.update(set_data)
    user.json=json.dumps(data)
    db.session.add(user)
    db.session.commit()

    ret_data={}
    ret_data['version']=1.0
    ret_data['status']=0    
    return jsonify(ret_data)
示例#3
0
文件: app.py 项目: beordle/jnu.fm
def set_background():
    args=request.args
    print (args)
    token = args['token']

    username=getUsernameFromToken(token)
    #token不通过
    if not username:
            ret={
             'version': 1.0,
             'status': 2,
             }
            return jsonify(ret)

    file = request.files['file']
    if file:
            filename = username+'.png'
            filepath=os.path.join(app.config['BACKGROUND_FOLDER'], filename)
            file.save(os.path.join(app.config['BACKGROUND_FOLDER'], filename))

            ret={
             'version': 1.0,
             'status': 0,
             'url': '/static/background/'+filename,
             }
            return jsonify(ret)



    return jsonify(ret_data)
示例#4
0
def set_info():
    args = request.args
    token = args['token']
    username = getUsernameFromToken(token)
    #token不通过
    if not username:
        ret = {
            'version': 1.0,
            'status': 2,
        }
        return jsonify(ret)

    user = User.query.filter_by(username=username).one()
    data = json.loads(user.json)

    set_data = {}
    set_list = ["nickname", "realname", "sex", "signature"]
    for key, value in args.items():
        if key in set_list:
            print(key)
            set_data[key] = value
    data.update(set_data)
    user.json = json.dumps(data)
    db.session.add(user)
    db.session.commit()

    ret_data = {}
    ret_data['version'] = 1.0
    ret_data['status'] = 0
    return jsonify(ret_data)
示例#5
0
文件: app.py 项目: beordle/jnu.fm
def get_class_by_auth():

    jwcpw = request.args['jwcpw']
    token = request.args['token']
    year = request.args['year']
    term = request.args['term']
    year, term = int(year), int(term)
    username = getUsernameFromToken(token)

    if not username:
        return jsonify(version=1.0, status='AuthNotPass')
    else:
        user = User.query.filter_by(username=username).one()
        data = json.loads(user.json)
        id, pw = data['jwcid'], jwcpw
    return jsonify(version=1.0, data=get_class_table2(id, pw, year, term))
示例#6
0
文件: app.py 项目: beordle/jnu.fm
def get_username():
    args=request.args
    token = args['token']
    username=getUsernameFromToken(token)
    #token不通过
    if not username:
            ret={
             'version': 1.0,
             'status': 2,
             }
            return jsonify(ret)
    ret={
             'version': 1.0,
             'username':username,
             'status': 0,
    }

    return jsonify(ret)
示例#7
0
def get_username():
    args = request.args
    token = args['token']
    username = getUsernameFromToken(token)
    #token不通过
    if not username:
        ret = {
            'version': 1.0,
            'status': 2,
        }
        return jsonify(ret)
    ret = {
        'version': 1.0,
        'username': username,
        'status': 0,
    }

    return jsonify(ret)
示例#8
0
文件: app.py 项目: beordle/jnu.fm
def sync():

    args = hebing(request.form, request.args)
    token = args.get('token')
    username = getUsernameFromToken(token)

    dic = delete(dic)
    return_val = dict(
        version=1.0,
        data=None
    )
    q = User.query.filter_by(username=username).all()
    user = q[0]
    dic = json.loads(user.json)

    user.json = json.dumps(dic)
    db.session.add(user)
    db.session.commit()
    return_val['data'] = delete(dic)
    return jsonify(return_val)
示例#9
0
def get_info():
    args = request.args
    token = args['token']
    username = args['username']

    self_username = getUsernameFromToken(token)
    #token不通过
    if not self_username:
        ret = {
            'version': 1.0,
            'status': 2,
        }
        return jsonify(ret)

    q = User.query.filter_by(username=username).all()
    #用户不存在
    if len(q) == 0:
        ret = {
            'version': 1.0,
            'status': 4,
        }
        return jsonify(ret)

    user = q[0]
    data = json.loads(user.json)
    ret_data = {}
    ret_list = [
        "nickname", "realname", "sex", "signature", "avatar", "background"
    ]
    for key, value in data.items():
        if key in ret_list:
            ret_data[key] = value
    if data.has_key('tid'):
        ret_data['avatar'] = '/static/avatar/' + username + '-' + data[
            'tid'] + '.png'
        ret_data['background'] = '/static/background/' + username + '-' + data[
            'tid'] + '.png'
    ret_data['version'] = 1.0
    ret_data['status'] = 0
    return jsonify(ret_data)
示例#10
0
文件: app.py 项目: beordle/jnu.fm
def set_avatar():
    args=request.args
    print (args)
    token = args['token']
    import time
    tid=str(time.time())
    username=getUsernameFromToken(token)
    #token不通过
    if not username:
            ret={
             'version': 1.0,
             'status': 2,
             }
            return jsonify(ret)

    user = User.query.filter_by(username=username).one()
    data = json.loads(user.json)
    data['tid']=tid
    user.json=json.dumps(data)
    db.session.add(user)
    db.session.commit()

    file = request.files['file']
    if file:
            filename = username+'-'+tid+'.png'
            filepath=os.path.join(app.config['HEADER_FOLDER'], filename)
            file.save(os.path.join(app.config['HEADER_FOLDER'], filename))

            ret={
             'version': 1.0,
             'status': 0,
             'url': "/static/avatar/"+filename,
             }
            return jsonify(ret)



    return jsonify(ret_data)
示例#11
0
文件: app.py 项目: beordle/jnu.fm
def get_info():
    args=request.args
    token = args['token']
    username = args['username']

    self_username=getUsernameFromToken(token)
    #token不通过
    if not self_username:
            ret={
             'version': 1.0,
             'status': 2,
             }
            return jsonify(ret)

    q = User.query.filter_by(username=username).all()
    #用户不存在
    if len(q)==0:
            ret={
             'version': 1.0,
             'status': 4,
             }
            return jsonify(ret)
    
    user=q[0]
    data = json.loads(user.json) 
    ret_data={}
    ret_list=["nickname","realname","sex","signature","avatar","background"]
    for key,value in data.items():
        if key in ret_list:
            ret_data[key]=value
    if data.has_key('tid'):
        ret_data['avatar']='/static/avatar/'+username+'-'+data['tid']+'.png'
        ret_data['background']='/static/background/'+username+'-'+data['tid']+'.png'
    ret_data['version']=1.0
    ret_data['status']=0    
    return jsonify(ret_data)
示例#12
0
def set_avatar():
    args = request.args
    print(args)
    token = args['token']
    import time
    tid = str(time.time())
    username = getUsernameFromToken(token)
    #token不通过
    if not username:
        ret = {
            'version': 1.0,
            'status': 2,
        }
        return jsonify(ret)

    user = User.query.filter_by(username=username).one()
    data = json.loads(user.json)
    data['tid'] = tid
    user.json = json.dumps(data)
    db.session.add(user)
    db.session.commit()

    file = request.files['file']
    if file:
        filename = username + '-' + tid + '.png'
        filepath = os.path.join(app.config['HEADER_FOLDER'], filename)
        file.save(os.path.join(app.config['HEADER_FOLDER'], filename))

        ret = {
            'version': 1.0,
            'status': 0,
            'url': "/static/avatar/" + filename,
        }
        return jsonify(ret)

    return jsonify(ret_data)