def mobile_syncrun(): if request.headers["Content-Type"] == "application/json": runjson = request.get_json() else: return redirect(url_for("home")) try: print "Run JSON Request", runjson if "id" in runjson: run = Run.query.filter_by(id=runjson["id"]).first() run.time = runjson["time"] else: run = Run(runjson["time"]) person = get_person(runjson["person"]) run.person = person.id run.fetcher = person run.time = runjson["time"] run.cafe = runjson["cafe"] run.pickup = runjson["pickup"] run.is_open = runjson["is_open"] run.statusobj = Status.query.filter_by(id=runjson["status"]).first() if "id" not in runjson: db.session.add(run) db.session.commit() return jsonify(msg="success", id=run.id, modified=run.jsondatetime("modified")) except: return jsonify(msg="error")