Exemple #1
0
def update_single_spot(id):
    eyed = id
    items = request.form.to_dict()
    avail = [k for k in items.keys() if items[k]]
    #dude, that's ugly. so many queries.
    cur = database.query_db('select * from spots where id=?',[eyed],one=True)
    if not cur:
        abort(404)
    for a in avail:
        try:
            #this doesn't seem secure
            g.db.execute('update spots set %s=? where id=?'%str(a), [items[a], eyed])
        except sqlite3.Error as e:
            return e
        finally:
            g.db.commit()
    return redirect(url_for('api.get_single_spot', id=eyed))
Exemple #2
0
def get_single_spot(id):
    cur = database.query_db('select * from spots where id=?',[id],one=True)
    if cur:
        return json.jsonify(cur)
    else:
        abort(404)
Exemple #3
0
def get_spots():
    cur = database.query_db('select * from spots')
    d = []
    for a in cur:
        d.append(dict(a))
    return json.jsonify(results=d)