Пример #1
0
def create_ad(user_id):
    ad_data = request.get_json(force=True, silent=True)
    if ad_data == None:
        return "Bad request", 400
    ad = Ad(user_id, ad_data["title"], ad_data["desc"], ad_data["price"], ad_data["date"], None, 1, None)
    ad.save()
    return json.dumps(ad.to_dict()), 201
Пример #2
0
def create_ad():
    ad_data = request.get_json(force=True, silent=True)
    if ad_data == None:
        return "Bad request", 400
    ad = Ad(ad_data["title"], ad_data["content"], ad_data["price"],
            ad_data["release_date"], ad_data["is_active"], ad_data["buyer"],
            ad_data["creator_id"])
    ad.save()
    return jsonify(ad.to_dict()), 201
Пример #3
0
def create_ad_postman():
    ad_data = request.get_json(force=True, silent=True)
    if ad_data == None:
        print(ad_data)
        return "Bad request", 400
    ad = Ad(ad_data["id"], ad_data["title"], ad_data["description"],
            ad_data["price"], ad_data["date"], ad_data["is_active"],
            ad_data["owner_id"])
    ad.save()
    return json.dumps(ad.to_dict()), 201