def self():
    result = flask.jsonify({
        'id':
        flask.session['id'],
        'name':
        server.personalinfo(db, flask.session['id'])['name']
    })
    return result
示例#2
0
def personaldetail():
    id = flask.request.args.get('id')
    person = server.personalinfo(db, id)
    friends = server.friends_of(db, id)
    courses = server.courses_of(db, id)
    result = {
        "user_name": person["name"],
        "user_email": person["email"],
        "friends": friends,
        "courses": courses
    }
    return flask.jsonify(result)
示例#3
0
def review():
    if flask.request.method == "GET":
        id = flask.request.args.get('courseid')
        re = server.request_reviews(db, id)
        return flask.jsonify(re)
    elif flask.request.method == "POST":
        data = server.get_json()
        status = server.review(db, flask.session["id"], data["id"], data["review"], data["rating"])
        re = {
            "id": flask.session["id"],
            "name": server.personalinfo(db, flask.session["id"])["name"]
        }
        return flask.jsonify(re)
示例#4
0
def user_info():
    data = server.get_json()
    personal_info = server.personalinfo(db, data['id'])
    result = {
        "name": personal_info['id'],
        "followings": server.followings(db, data['id']),
        "followed": server.follows(db, data['id'], flask.session["id"]),
        "followers": server.followers(db, data['id']),
        "following": server.follows(db, flask.session["id"], data['id']),
        "courses": server.courses(db, data['id']),
        "dscr": personal_info['dscr'],
    }
    print(server.follows(db, '123', '123'))
    return flask.jsonify(result)