Add index position

This commit is contained in:
Andros Fenollosa 2018-04-05 09:19:37 +02:00
parent dd63956507
commit 71d8c9e08e

11
app.py
View File

@ -25,14 +25,21 @@ CORS(app, resources={r"/api/*": {"origins": "*"}})
# Routes # Routes
# ========================= # =========================
# Get data from index
@app.route(PRE_URL + 'index/<int:id>')
def index(id):
match = POSTALS.loc[[id]]
return match.reset_index().to_json(orient='records')
# Get data from postal code # Get data from postal code
@app.route(PRE_URL + 'geolocation/<int:code>') @app.route(PRE_URL + 'postal_code/<int:code>')
def geolocation(code): def postal_code(code):
match = POSTALS[POSTALS['postal_code'].isin([code])] match = POSTALS[POSTALS['postal_code'].isin([code])]
results = match.filter(items=['postal_code', 'poblacion', 'lat', 'lng']) results = match.filter(items=['postal_code', 'poblacion', 'lat', 'lng'])
return results.reset_index().to_json(orient='records') return results.reset_index().to_json(orient='records')
if __name__ == "__main__": if __name__ == "__main__":
app.run() app.run()