-
Notifications
You must be signed in to change notification settings - Fork 0
/
01_webhook.py
55 lines (48 loc) · 1.69 KB
/
01_webhook.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
from flask import request, url_for
from flask_api import FlaskAPI, status, exceptions
from utils import *
import os
import ast
from flask import jsonify
app = FlaskAPI(__name__)
@app.route("/edo/", methods=['GET'])
def get_correct_edo():
"""
List or create notes.
"""
if request.method == 'GET':
estado = request.args.get('nombre')
estado_nombre,clave = correct_edo(estado)
return jsonify({"nombre":estado_nombre, "cve":clave })
@app.route("/mun/", methods=['GET'])
def get_correct_mun():
"""
List or create notes.
"""
if request.method == 'GET':
mun = request.args.get('nombre')
estado = request.args.get('estado')
mun_nombre,clave = correct_mun(estado, mun)
return jsonify({"nombre": mun_nombre, "cve":clave})
@app.route("/corner/", methods=['GET', 'POST'])
def get_location_with_corner():
"""
List or create notes.
"""
if request.method == 'GET':
street_a = str(request.args.get('street_a'))
street_b = str(request.args.get('street_b'))
municipio = str(request.args.get('municipio'))
location = get_location_with_corner_municipio(municipio,street_a,street_b)
return jsonify(location)
@app.route("/country/", methods=['GET'])
def get_correct_country():
country = request.args.get('nombre')
lng = request.args.get('lng')
lng = lng if lng in ["spa","eng","hol","por"] else ""
country_nombre = correct_country(country, lng)
return jsonify({"clave": country_nombre})
if __name__ == "__main__":
#Cambiar ip a 0.0.0.0
app.config['TEMPLATES_AUTO_RELOAD'] = True
app.run(debug=True,host="0.0.0.0", port= int(os.getenv('WEBHOOK_PORT', 5000)))