Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/env python
- import googlemaps
- from datetime import datetime
- from flask import Flask, jsonify, request, render_template
- from flask_googlemaps import GoogleMaps
- from flask_googlemaps import Map
- app = Flask(__name__)
- key ="AIzaSyChUm3S41NRm2N2QAyLCUhPuydaRZg1XYo"
- app.config['GOOGLEMAPS_KEY'] = key
- GoogleMaps(app)
- gmaps = googlemaps.Client(key="")
- SWISS_COORD = (46.83, 8.05)
- # @app.route("/api/swissmap")
- # def mapview():
- # # creating a map in the view
- # mymap = Map(
- # identifier="view-side",
- # lat= SWISS_COORD[0],
- # lng=SWISS_COORD[1]
- # )
- # # render_template('example.html', mymap=mymap)
- # return jsonify(mymap.as_json())
- @app.route('/api/keywords', methods = ['POST'])
- def get_maps():
- params = request.form # get form data
- keyword = params['keyword']
- radius = params['radius'] or 500000
- d = gmaps.places_autocomplete_query(keyword, location=SWISS_COORD, radius=radius)
- # d = gmaps.places_nearby(location=SWISS_COORD, keyword=keyword)
- return jsonify(d)
- if __name__ == '__main__':
- app.run(debug=True)
Advertisement
Add Comment
Please, Sign In to add comment