Beispiel #1
0
def add_or_get_offers():
    wants_json = request_wants_json()
    params = json.loads(request.form['params'])
    try:
        if request.method == 'GET':
            offers = api.get_all_offers(json=wants_json)
            return jsonify({'offer': offers})
        elif request.method == 'POST':
            api.create_offer(**params)
            resp = jsonify(message='success!')
            resp.status_code = 201
            return resp
    except api.DbNotFoundError:
        abort(404)
Beispiel #2
0
def index():
    page = int(request.args.get('page', 1))
    offers = api.get_all_offers(page=page)
    return render_template('index.html', offers=offers, page=page)