コード例 #1
0
def insert():
    param_dict = request.args.to_dict()
    try:
        insert_user(g.session, param_dict)
        return encrypt_aes(json.dumps({"code": "1"}))
    except Exception:
        return encrypt_aes(json.dumps({"code": "0"}))
コード例 #2
0
def add_item():
    param_dict = request.args.to_dict()
    try:
        insert_item(g.session, param_dict)
        return encrypt_aes(json.dumps({"code": "1"}))
    except:
        return encrypt_aes(json.dumps({"code": "0"}))
コード例 #3
0
def login():
    param_dict = request.args.to_dict()
    if "username" in param_dict.keys() and "passwordsalt" in param_dict.keys():
        if exists_user(g.session, param_dict["username"],
                       param_dict["passwordsalt"]):
            return encrypt_aes(json.dumps({"code": "1"}))
    return encrypt_aes(json.dumps({"code": "0"}))
コード例 #4
0
def update():
    param_dict = request.args.to_dict()
    try:
        update_user(g.session, param_dict)
    except:
        return encrypt_aes(json.dumps({"code": "0"}))
    return encrypt_aes(json.dumps({"code": "1"}))
コード例 #5
0
def add_record():
    param_dict = request.args.to_dict()
    try:
        print(1)
        insert_records(g.session, param_dict)
        return encrypt_aes(json.dumps({"code": "1"}))
    except:
        return encrypt_aes(json.dumps({"code": "0"}))
コード例 #6
0
def upload():
    if request.method == 'POST':
        f = request.files["file"]
        filename = str(time.time()) + f.filename
        try:
            update_user_image(g.session,
                              request.args.to_dict()["username"], filename)
            f.save(UPLOAD + filename)
            return encrypt_aes(json.dumps({"code": "1"}))
        except Exception:
            return encrypt_aes(json.dumps({"code": "0"}))
    else:
        return encrypt_aes(json.dumps({"code": "0"}))
コード例 #7
0
def get_item():
    all_items = get_items(g.session)
    item_lis = []
    for item in all_items:
        item_lis.append(
            json.dumps({
                "itemname": item.itemname,
                "description": item.description,
                "amount": item.amount,
                "username": get_username_by_id(g.session, item._user_id)
            }))
    return encrypt_aes(str(item_lis))
コード例 #8
0
def getuser():
    param_dict = request.args.to_dict()
    user = get_user(g.session, param_dict["username"])
    # username phone image_src email sign rights
    return encrypt_aes(
        json.dumps({
            "username": user.username,
            "phone": user.phone,
            "image_src": user.image_src,
            "email": user.email,
            "sign": user.sign,
            "rights": user.rights,
        }))
コード例 #9
0
def get_record():
    all_records = get_records(g.session)
    record_lis = []
    for record in all_records:
        record_lis.append(
            json.dumps({
                "itemname":
                get_itemname_by_id(g.session, record.item_id),
                "username":
                get_username_by_id(g.session, record.user_id),
                "last_use_time":
                record.last_use_time,
                "state":
                record.state
            }))
    return encrypt_aes(str(record_lis))