<commit_before>from os import environ
from urllib2 import urlopen

from flask import Flask, json, make_response
app = Flask(__name__)

url = 'http://open.mapquestapi.com/directions/v2/route'
params = '?key={apikey}&ambiguities=ignore&routeType=pedestrian'
rel = url + params + '&from={flat},{flng}&to={tlat},{tlng}'


@app.route("/route/<from_lat>,<from_lng>/<to_lat>,<to_lng>")
def get_coords(from_lat, from_lng, to_lat, to_lng):
    resp = urlopen(rel.format(apikey=environ['MAPQUEST_API_KEY'],
                   flat=from_lat, flng=from_lng, tlat=to_lat, tlng=to_lng))

    resp_dict = json.loads(resp.read().decode("utf-8"))
    res = [(man['startPoint']['lat'], man['startPoint']['lng'])
           for leg in resp_dict['route']['legs']
           for man in leg['maneuvers']]
    return make_response(json.dumps(res))

if __name__ == "__main__":
    app.run(debug=environ.get('FLASK_DEBUG', False))<commit_msg>Return route, hip rank and total rank<commit_after>from os import environ
from urllib2 import urlopen

from flask import Flask, json, jsonify
app = Flask(__name__)

from hip import get_ranking_array

url = 'http://open.mapquestapi.com/directions/v2/route'
params = '?key={apikey}&ambiguities=ignore&routeType=pedestrian'
rel = url + params + '&from={flat},{flng}&to={tlat},{tlng}'


@app.route("/route/<from_lat>,<from_lng>/<to_lat>,<to_lng>")
def route(from_lat, from_lng, to_lat, to_lng):
    resp = urlopen(rel.format(apikey=environ['MAPQUEST_API_KEY'],
                   flat=from_lat, flng=from_lng, tlat=to_lat, tlng=to_lng))

    route = json.loads(resp.read().decode("utf-8"))
    coords = [(man['startPoint']['lat'], man['startPoint']['lng'])
              for leg in route['route']['legs']
              for man in leg['maneuvers']]
    hip_rank, total_rank = get_ranking_array(coords)
    return jsonify(route=route, hip_rank=list(hip_rank), total_rank=total_rank)

if __name__ == "__main__":
    app.run(debug=environ.get('FLASK_DEBUG', False))
{'fraction_non_alphanumeric': 0.16666666666666666, 'fraction_numerical': 0.00303951367781155, 'mean_word_length': 5.003039513677812, 'pattern_counts': {'":': 2, '<': 11, '<?xml version=': 0, '>': 11, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5229930', 'n_tokens_mistral': 722, 'n_tokens_neox': 719, 'n_words': 126}