Skip to content

Instantly share code, notes, and snippets.

@nfarah86
Last active May 7, 2016 00:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nfarah86/a90720050fa979424cc6306a4e26b373 to your computer and use it in GitHub Desktop.
Save nfarah86/a90720050fa979424cc6306a4e26b373 to your computer and use it in GitHub Desktop.
iOS App Makes an API Call to /update_run
// omitted code
@app.route("/update_run", methods = ['POST'])
def update_run():
if not request.json["user_name"]:
return json.dumps({ 'error': True })
user_name = request.json['user_name'] #getting from iphone
password = request.json['password'] #getting from iphone
email = request.json['email'] #getting from iphone
user = db_session.query(User).filter_by(
user_name = user_name,
password = password).first()
app.logger.warning('This is name stuff: %s, %s, %s' % (user_name, password, email))
latValues = request.json["latitude"] #gps coord. from iphone
longValues = request.json["longitude"] #gps coord. from iphone
app.logger.warning('This is: %s, %s' % (latValues, longValues))
for k, v in enumerate(latValues):
app.logger.warning('This is putting to db k,v: %s, %s' % (k, v))
app.logger.warning('This is: %s, %s, %s' % (v, latValues, longValues))
gps_location = GPS_Location(
latitude = latValues[k],
longitude = longValues[k],
user_id = user.id)
db_session.add(gps_location)
print latValues[k]
print longValues[k]
app.logger.warning('This is: %s, %s, %s' % (v, latValues[k], longValues[k]))
app.logger.warning('This is gps loc: %s' % (gps_location))
db_session.commit()
return json.dumps({ 'success': True })
// omitted code
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment