Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- @app.route("/population")
- def status():
- conn = sqlite3.connect('population.db')
- conn.row_factory = sqlite3.Row
- db = conn.cursor()
- rows = db.execute('''
- SELECT * from info
- ''').fetchall()
- conn.commit()
- conn.close()
- json_format = [dict(ix) for ix in rows]
- geojson = {
- "type": "FeatureCollection",
- "features": [
- {
- "type": "Feature",
- "geometry" : {
- "type": "Point",
- "coordinates": [data["LONG"], data["LAT"]],
- },
- "properties" : {
- 'name':data['NAME'],
- 'population':data['POPULATION']
- }
- } for data in json_format]
- }
- return jsonify(geojson)
Add Comment
Please, Sign In to add comment