예제 #1
0
파일: api.py 프로젝트: StyXman/trip-planner
    def post (self, name):
        """This method extends the RESTful convention to implement UPSERT"""
        q= session.query (Trip).filter_by (name=name)
        if q.count ()==0:
            # INSERT
            trip= Trip.fromJson (request.form['trip'])
        else:
            # UPDATE
            trip= q.first ()
            trip.updatePoints (request.form['trip'])

        session.add (trip)
        session.commit ()

        return trip.toJson (), 201, CORPSE
예제 #2
0
파일: api.py 프로젝트: StyXman/trip-planner
 def post (self):
     # trip={ "name": "default", "points": [ [ 43.55277819471542, 6.934947967529298 ], [ 43.581136968065685, 6.942672729492188 ] ] }
     trip= Trip.fromJson (request.form['trip'])
     session.add (trip)
     session.commit ()
     return trip.toJson (), 201, CORPSE