예제 #1
0
파일: api.py 프로젝트: killerbat00/tpss
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))
예제 #2
0
파일: api.py 프로젝트: killerbat00/tpss
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))
예제 #3
0
파일: api.py 프로젝트: killerbat00/tpss
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)
예제 #4
0
파일: api.py 프로젝트: killerbat00/tpss
def get_spots():
    cur = database.query_db('select * from spots')
    d = []
    for a in cur:
        d.append(dict(a))
    return json.jsonify(results=d)
예제 #5
0
파일: api.py 프로젝트: killerbat00/tpss
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)
예제 #6
0
파일: api.py 프로젝트: killerbat00/tpss
def get_spots():
    cur = database.query_db('select * from spots')
    d = []
    for a in cur:
        d.append(dict(a))
    return json.jsonify(results=d)