from flask import Flask, request
from pymongo import MongoClient
import os
import json
import pprint
app = Flask(__name__)

client = MongoClient(os.environ["MONGOLAB_URI"])
db = client["heroku_gw4w78g9"]
col = db["locations"]
print col

@app.route('/location', methods=["POST"])
def addLocation():
  print "REQUEST.JSON"
  print "---", request.json, "---"
  print "---", col.insert_one(request.data)
  

@app.route('/')
def hello_world():
  locs = [d for d in col.find({})]
  print pprint.pformat(locs)
  return pprint.pformat(locs)

if __name__ == '__main__':
  app.run(debug=True)

@@ -291,16 +291,25 @@
 tion():%0A
+  try:%0A  
   print 
@@ -322,24 +322,17 @@
 ST.JSON%22
-%0A  print
+,
  %22---%22, 
@@ -357,20 +357,9 @@
 %22%0A  
-print %22---%22,
+ 
  col
@@ -382,12 +382,91 @@
 est.
-data
+json)%0A  except Exception as e:%0A    import traceback%0A    print traceback.format_exc(
 )%0A  

update server