Guest User

Untitled

a guest
Nov 15th, 2018
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.72 KB | None | 0 0
  1. @app.route("/population")
  2. def status():
  3. conn = sqlite3.connect('population.db')
  4. conn.row_factory = sqlite3.Row
  5. db = conn.cursor()
  6. rows = db.execute('''
  7. SELECT * from info
  8. ''').fetchall()
  9.  
  10. conn.commit()
  11. conn.close()
  12.  
  13. json_format = [dict(ix) for ix in rows]
  14. geojson = {
  15. "type": "FeatureCollection",
  16. "features": [
  17. {
  18. "type": "Feature",
  19. "geometry" : {
  20. "type": "Point",
  21. "coordinates": [data["LONG"], data["LAT"]],
  22. },
  23. "properties" : {
  24.  
  25. 'name':data['NAME'],
  26. 'population':data['POPULATION']
  27. }
  28. } for data in json_format]
  29. }
  30.  
  31. return jsonify(geojson)
Add Comment
Please, Sign In to add comment