Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in
Toggle navigation
W
Webservice Marcimex
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Luis Acosta
Webservice Marcimex
Commits
27792f80
Commit
27792f80
authored
Jan 09, 2025
by
Luis Acosta
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
version Version 1.0.5
parent
648a3538
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
359 additions
and
113 deletions
+359
-113
.gitignore
.gitignore
+3
-0
Connect_CC2.py
Connect_CC2.py
+2
-2
app.py
app.py
+13
-5
app_local.py
app_local.py
+280
-0
functions.py
functions.py
+61
-106
No files found.
.gitignore
0 → 100644
View file @
27792f80
.env
venv
__pycache__
Connect_CC2.py
View file @
27792f80
import
requests
import
requests
import
json
import
json
class
Callcenter
:
class
Callcenter
:
def
__init__
(
self
,
api_key
,
url
):
def
__init__
(
self
,
api_key
,
url
,
user_center_id
):
self
.
url
=
url
self
.
url
=
url
# Paso 1: Hacer un POST para obtener el token
# Paso 1: Hacer un POST para obtener el token
requests
.
packages
.
urllib3
.
disable_warnings
()
requests
.
packages
.
urllib3
.
disable_warnings
()
...
@@ -11,7 +11,7 @@ class Callcenter:
...
@@ -11,7 +11,7 @@ class Callcenter:
self
.
token
=
response
.
json
()[
"token"
]
self
.
token
=
response
.
json
()[
"token"
]
# Paso 2: Enviar un GET con el token obtenido en el encabezado y obtener la Cookie
# Paso 2: Enviar un GET con el token obtenido en el encabezado y obtener la Cookie
self
.
user_center_id
=
42
self
.
user_center_id
=
user_center_id
url_center
=
f
"{self.url}/api/centers/select/{self.user_center_id}"
url_center
=
f
"{self.url}/api/centers/select/{self.user_center_id}"
headers
=
{
"CCAuthorization"
:
f
"Bearer {self.token}"
}
headers
=
{
"CCAuthorization"
:
f
"Bearer {self.token}"
}
response
=
requests
.
get
(
url_center
,
headers
=
headers
,
verify
=
False
)
response
=
requests
.
get
(
url_center
,
headers
=
headers
,
verify
=
False
)
...
...
app.py
View file @
27792f80
...
@@ -17,8 +17,15 @@ db_call_center = os.getenv("DB_NAME_CALL_CENTER")
...
@@ -17,8 +17,15 @@ db_call_center = os.getenv("DB_NAME_CALL_CENTER")
#db_name_cdr = os.getenv("DB_NAME_CDR")
#db_name_cdr = os.getenv("DB_NAME_CDR")
db_name_hiper_service
=
os
.
getenv
(
"DB_NAME_HIPER_SERVICE"
)
db_name_hiper_service
=
os
.
getenv
(
"DB_NAME_HIPER_SERVICE"
)
cc_url
=
'https://mxcc-gruposerviandina.hiperpbx.com'
#cc_url = 'https://mxcc-gruposerviandina.hiperpbx.com'
api_key
=
'07j3FHMnDNrIV43A2eB8BlNEDEf1FVXQQtDuNm82jaPANIetnYTiL97QzenOdlbGKEqyd8rtD0HQWtaQ'
#cc_url = 'https://mxcc-serviandina-marcimex.hiperpbx.com'
#api_key = '07j3FHMnDNrIV43A2eB8BlNEDEf1FVXQQtDuNm82jaPANIetnYTiL97QzenOdlbGKEqyd8rtD0HQWtaQ'
cc_url
=
os
.
getenv
(
"URL_CC"
)
api_key
=
os
.
getenv
(
"API_KEY_CC"
)
user_center_id
=
os
.
getenv
(
"CENTER_ID_CC"
)
print
(
timedelta
(
minutes
=
int
(
os
.
getenv
(
"JWT_ACCESS_TOKEN_EXPIRES"
,
5
))))
hm_url
=
'https://mxme.hiperpbx.com'
hm_url
=
'https://mxme.hiperpbx.com'
hm_api_key
=
'c4ce8a7f84c01674d573d4df5cf2e410'
hm_api_key
=
'c4ce8a7f84c01674d573d4df5cf2e410'
hm_email
=
'serviceaccount@serviandina.com'
hm_email
=
'serviceaccount@serviandina.com'
...
@@ -152,7 +159,7 @@ def Generate_Campaign():
...
@@ -152,7 +159,7 @@ def Generate_Campaign():
actualizar_campaign
=
db_cc
.
actualizar
(
"update campaign set datetime_init =
%
s, datetime_end =
%
s, daytime_init =
%
s, daytime_end =
%
s, estatus =
%
s where id =
%
s "
,(
f
'{str(date_ini_camp)}'
,
f
'{str(date_fin_camp)}'
,
f
'{str(time_ini_camp)}'
,
f
'{str(time_fin_camp)}'
,
f
'{camp_status}'
,
f
'{camp_id_search}'
))
actualizar_campaign
=
db_cc
.
actualizar
(
"update campaign set datetime_init =
%
s, datetime_end =
%
s, daytime_init =
%
s, daytime_end =
%
s, estatus =
%
s where id =
%
s "
,(
f
'{str(date_ini_camp)}'
,
f
'{str(date_fin_camp)}'
,
f
'{str(time_ini_camp)}'
,
f
'{str(time_fin_camp)}'
,
f
'{camp_status}'
,
f
'{camp_id_search}'
))
#Conectar al CC2 para insertar datos en la la campaña
#Conectar al CC2 para insertar datos en la la campaña
callcenter
=
Callcenter
(
api_key
,
cc_url
)
callcenter
=
Callcenter
(
api_key
,
cc_url
,
user_center_id
)
#id_campaign= 87 #Modificar por el valor ingresado
#id_campaign= 87 #Modificar por el valor ingresado
response
=
callcenter
.
search_campaing
(
camp_id_search
)
response
=
callcenter
.
search_campaing
(
camp_id_search
)
data
=
response
.
json
()[
'id'
]
data
=
response
.
json
()[
'id'
]
...
@@ -166,7 +173,7 @@ def Generate_Campaign():
...
@@ -166,7 +173,7 @@ def Generate_Campaign():
#return jsonify({"mensaje": f"Camp Ingreso Datos: {camp_data_input} Camp Resultado: {camp_data_search} Comparacion: {result} Resgistros: {payload}"}), 200
#return jsonify({"mensaje": f"Camp Ingreso Datos: {camp_data_input} Camp Resultado: {camp_data_search} Comparacion: {result} Resgistros: {payload}"}), 200
return
jsonify
({
"mensaje"
:
f
"Campaing ,ID: {camp_id_search} Name: {camp_name_search} Status: {camp_status_search} Registros Ingresados"
}),
200
return
jsonify
({
"mensaje"
:
f
"Campaing ,ID: {camp_id_search} Name: {camp_name_search} Status: {camp_status_search} Registros Ingresados"
}),
200
else
:
else
:
callcenter
=
Callcenter
(
api_key
,
cc_url
)
callcenter
=
Callcenter
(
api_key
,
cc_url
,
user_center_id
)
cread_camp
=
callcenter
.
created_campaing
(
camp_name
,
date_ini_camp
,
time_ini_camp
,
date_fin_camp
,
time_fin_camp
,
campaign_queue
,
camp_obsv
)
cread_camp
=
callcenter
.
created_campaing
(
camp_name
,
date_ini_camp
,
time_ini_camp
,
date_fin_camp
,
time_fin_camp
,
campaign_queue
,
camp_obsv
)
#print(cread_camp)
#print(cread_camp)
id_camp
=
json
.
loads
(
cread_camp
)[
"id"
]
id_camp
=
json
.
loads
(
cread_camp
)[
"id"
]
...
@@ -218,7 +225,8 @@ def Consult_Campaign():
...
@@ -218,7 +225,8 @@ def Consult_Campaign():
campaign_date_ini
=
request_data
[
"date_in"
]
campaign_date_ini
=
request_data
[
"date_in"
]
campaign_date_fin
=
request_data
[
"date_out"
]
campaign_date_fin
=
request_data
[
"date_out"
]
#Buscar Campaña
#Buscar Campaña
callcenter
=
Callcenter
(
api_key
,
cc_url
)
print
(
cc_url
)
callcenter
=
Callcenter
(
api_key
,
cc_url
,
user_center_id
)
consult_calls
=
callcenter
.
consult_campaing
(
campaign_id
,
campaign_date_ini
,
campaign_date_fin
)
consult_calls
=
callcenter
.
consult_campaing
(
campaign_id
,
campaign_date_ini
,
campaign_date_fin
)
data_response
=
json
.
loads
(
consult_calls
)[
"hydra:member"
]
data_response
=
json
.
loads
(
consult_calls
)[
"hydra:member"
]
message
=
{
'responce'
:
data_response
}
message
=
{
'responce'
:
data_response
}
...
...
app_local.py
0 → 100644
View file @
27792f80
import
os
import
json
from
Connect_CC2
import
Callcenter
from
functions
import
convertir_fecha_hora
,
check_date_in_out
,
limpiar_texto
,
status_camp
,
valid_array_fields
,
valid_array_data
,
convertir_hora
from
datetime
import
datetime
,
timedelta
from
dotenv
import
load_dotenv
from
flask
import
Flask
,
request
,
jsonify
,
render_template
,
redirect
,
url_for
,
session
,
flash
from
Connect_Db
import
MySQLDatabase
from
flask_jwt_extended
import
JWTManager
,
create_access_token
,
create_refresh_token
,
jwt_required
,
get_jwt_identity
#db_host = os.getenv("DB_HOST")
#db_user = os.getenv("DB_USER")
#db_pass = os.getenv("DB_PASS")
db_call_center
=
os
.
getenv
(
"DB_NAME_CALL_CENTER"
)
db_host
=
'localhost'
db_user
=
'root'
db_pass
=
''
db_call_center
=
os
.
getenv
(
"DB_NAME_CALL_CENTER"
)
#db_name_asterisk = os.getenv("DB_NAME_ASTERISK")
#db_name_cdr = os.getenv("DB_NAME_CDR")
db_name_hiper_service
=
os
.
getenv
(
"DB_NAME_HIPER_SERVICE"
)
cc_url
=
'https://mxcc-gruposerviandina.hiperpbx.com'
api_key
=
'07j3FHMnDNrIV43A2eB8BlNEDEf1FVXQQtDuNm82jaPANIetnYTiL97QzenOdlbGKEqyd8rtD0HQWtaQ'
app
=
Flask
(
__name__
)
app
.
config
[
"JWT_SECRET_KEY"
]
=
os
.
getenv
(
"JWT_SECRET_KEY"
,
"clave_por_defecto"
)
app
.
config
[
"JWT_ACCESS_TOKEN_EXPIRES"
]
=
timedelta
(
minutes
=
int
(
os
.
getenv
(
"JWT_ACCESS_TOKEN_EXPIRES"
,
5
)))
app
.
config
[
"JWT_REFRESH_TOKEN_EXPIRES"
]
=
timedelta
(
days
=
int
(
os
.
getenv
(
"JWT_REFRESH_TOKEN_EXPIRES"
,
1
)))
app
.
config
[
"JWT_TOKEN_LOCATION"
]
=
os
.
getenv
(
"JWT_TOKEN_LOCATION"
,
"headers"
)
.
split
(
","
)
app
.
config
[
"JWT_HEADER_NAME"
]
=
os
.
getenv
(
"JWT_HEADER_NAME"
,
"Authorization"
)
app
.
config
[
"JWT_HEADER_TYPE"
]
=
os
.
getenv
(
"JWT_HEADER_TYPE"
,
"Bearer"
)
jwt
=
JWTManager
(
app
)
USUARIOS
=
{
"admin"
:
"1234"
}
fecha_hora
=
datetime
.
now
()
.
strftime
(
'
%
Y-
%
m-
%
d
%
H:
%
M:
%
S'
)
#formato_convertir_fecha = "%d/%m/%Y %H:%M:%S"
@
app
.
route
(
'/'
)
def
home
():
return
jsonify
({
"Mensaje"
:
"Hola"
}),
200
#return jsonify(resultado)
@
app
.
route
(
'/login'
,
methods
=
[
'POST'
])
def
login
():
datos
=
request
.
json
usuario
=
datos
.
get
(
"usuario"
)
contrasena
=
datos
.
get
(
"contrasena"
)
db
=
MySQLDatabase
(
host
=
db_host
,
user
=
db_user
,
password
=
""
,
database
=
db_name_hiper_service
)
resultado
=
db
.
consultar
(
"SELECT * FROM hiper_service_usuarios WHERE users =
%
s AND password =
%
s"
,(
f
'{usuario}'
,
f
'{contrasena}'
))
if
resultado
:
access_token
=
create_access_token
(
identity
=
usuario
)
refresh_token
=
create_refresh_token
(
identity
=
usuario
)
nuevo_id
=
db
.
insertar
(
"INSERT INTO hiper_service_accesos (usuario, token ,fecha_hora, status, message) VALUES (
%
s,
%
s,
%
s,
%
s,
%
s)"
,(
f
'{usuario}'
,
f
'{access_token}'
,
f
'{fecha_hora}'
,
'AccessToken'
,
'OK'
))
db
.
cerrar
()
return
jsonify
({
"access_token"
:
access_token
,
"refresh_token"
:
refresh_token
}),
200
else
:
nuevo_id
=
db
.
insertar
(
"INSERT INTO hiper_service_accesos (usuario, token ,fecha_hora, status, message) VALUES (
%
s,
%
s,
%
s,
%
s,
%
s)"
,(
f
'{usuario}'
,
''
,
f
'{fecha_hora}'
,
'AccessToken'
,
'Error'
))
db
.
cerrar
()
return
jsonify
({
"error"
:
"Access Token Error"
}),
401
@
app
.
route
(
'/Generate_Campaign'
,
methods
=
[
'GET'
])
@
jwt_required
()
def
Generate_Campaign
():
usuario
=
get_jwt_identity
()
db
=
MySQLDatabase
(
host
=
db_host
,
user
=
db_user
,
password
=
""
,
database
=
db_name_hiper_service
)
nuevo_id
=
db
.
insertar
(
"INSERT INTO hiper_service_accesos (usuario, token ,fecha_hora, status, message) VALUES (
%
s,
%
s,
%
s,
%
s,
%
s)"
,(
f
'{usuario}'
,
''
,
f
'{fecha_hora}'
,
'Generate Campaing'
,
'Access'
))
db
.
cerrar
()
request_data
=
request
.
get_json
()
dataCollection
=
request_data
[
"dataCollection"
]
campaign_id
=
request_data
[
"campaign_id"
]
campaign_name
=
request_data
[
"campaign_name"
]
campaign_date_ini
=
request_data
[
"campaign_date_ini"
]
campaign_date_fin
=
request_data
[
"campaign_date_fin"
]
campaign_queue
=
request_data
[
"campaign_queue"
]
campaign_status
=
request_data
[
"campaign_status"
]
campaign_observ
=
request_data
[
"campaign_observ"
]
campaign_fields
=
request_data
[
"fields"
]
campaign_data
=
request_data
[
"data"
]
#Validar campos de fecha y hora y diferencias de tiempos entre ambas
date_ini_check
=
convertir_fecha_hora
(
campaign_date_ini
)
date_ini_result
=
date_ini_check
[
0
]
date_ini_camp
=
date_ini_check
[
1
]
time_ini_camp
=
date_ini_check
[
2
]
date_fin_check
=
convertir_fecha_hora
(
campaign_date_fin
)
date_fin_result
=
date_fin_check
[
0
]
date_fin_camp
=
date_fin_check
[
1
]
time_fin_camp
=
date_fin_check
[
2
]
if
(
date_ini_result
==
True
&
date_fin_result
==
True
):
#Chequear diferencias de Tiempos entre ambas fechas y horas
date_in
=
str
(
date_ini_camp
)
+
' '
+
str
(
time_ini_camp
)
date_out
=
str
(
date_fin_camp
)
+
' '
+
str
(
time_fin_camp
)
check_date
=
check_date_in_out
(
date_in
,
date_out
)
if
(
check_date
==
False
):
return
jsonify
({
"mensaje"
:
f
"Error al generar Campaing , {campaign_name}! Fecha y Hora Inicial debe ser menor a Fecha y Hora Final"
}),
401
else
:
return
jsonify
({
"mensaje"
:
f
"Error al generar Campaing , {campaign_name}! Formato Invalido Fecha y Hora"
}),
401
#Validar nombres permitidos en campaña
check_name_camp
=
limpiar_texto
(
campaign_name
)
check_name_camp_result
=
check_name_camp
[
0
]
if
(
check_name_camp_result
==
True
):
camp_name
=
check_name_camp
[
1
]
else
:
return
jsonify
({
"mensaje"
:
f
"Error al generar Campaing , {campaign_name}! Formato Invalido Nombre de Campaña"
}),
401
#Validar Status Campaña
valid_status_camp
=
status_camp
(
campaign_status
)
valid_status_camp_result
=
valid_status_camp
[
0
]
if
(
valid_status_camp_result
==
True
):
camp_status
=
valid_status_camp
[
1
]
else
:
return
jsonify
({
"mensaje"
:
f
"Error al generar Campaing , {campaign_name}! Status Invalido de Campaña"
}),
401
#Validar nombres permitidos en observaciones
check_name_obsv
=
limpiar_texto
(
campaign_observ
)
check_name_obsv_result
=
check_name_obsv
[
0
]
if
(
check_name_obsv_result
==
True
):
camp_obsv
=
check_name_obsv
[
1
]
else
:
return
jsonify
({
"mensaje"
:
f
"Error al generar Campaing , {campaign_name}! Formato Invalido Observaciones"
}),
401
#Validar Campo Fields campo 0 =phone resto string
check_fields
=
valid_array_fields
(
campaign_fields
)
if
(
check_fields
[
0
]
==
True
):
check_field_cant
=
check_fields
[
1
]
check_field_data
=
check_fields
[
2
]
else
:
return
jsonify
({
"mensaje"
:
f
"Error al generar Campaing , {campaign_name}! Formato Invalido Fileds"
}),
401
#check_data=valid_array_data(campaign_data,check_field_cant)
#Modificacion debido que primer campo debe ser numerico
check_data
=
True
if
(
check_data
==
True
):
return_data
=
'ok'
else
:
return
jsonify
({
"mensaje"
:
f
"Error al generar Campaing , {campaign_name}! Formato Invalido Data"
}),
401
#Fin de validaciones
#Buscar el nombre de la campaña en la base de datos y tomar el valor del ID
db_cc
=
MySQLDatabase
(
host
=
db_host
,
user
=
db_user
,
password
=
""
,
database
=
db_call_center
)
resultado_campaign
=
db_cc
.
consultar
(
"SELECT * FROM campaign WHERE name =
%
s limit 1"
,(
f
'{camp_name}'
,))
if
resultado_campaign
:
for
registro
in
resultado_campaign
:
camp_id_search
=
registro
[
'id'
]
camp_name_search
=
registro
[
'name'
]
camp_status_search
=
registro
[
'estatus'
]
camp_datetime_init_search
=
registro
[
'datetime_init'
]
camp_datetime_end_search
=
registro
[
'datetime_end'
]
camp_daytime_init_search
=
str
(
registro
[
'daytime_init'
])
camp_daytime_end_search
=
str
(
registro
[
'daytime_end'
])
camp_queue_search
=
registro
[
'queue'
]
time_ini
=
convertir_hora
(
camp_daytime_init_search
)
time_out
=
convertir_hora
(
camp_daytime_end_search
)
camp_data_search
=
[
camp_status_search
,
str
(
camp_datetime_init_search
),
str
(
camp_datetime_end_search
),
time_ini
,
time_out
]
camp_data_input
=
[
camp_status
,
str
(
date_ini_camp
),
str
(
date_fin_camp
),
str
(
time_ini_camp
),
str
(
time_fin_camp
)]
if
(
camp_data_search
==
camp_data_input
):
result
=
"Datos Iguales"
else
:
result
=
'Datos Distintos'
#Update de registros en la campaña
actualizar_campaign
=
db_cc
.
actualizar
(
"update campaign set datetime_init =
%
s, datetime_end =
%
s, daytime_init =
%
s, daytime_end =
%
s, estatus =
%
s where id =
%
s "
,(
f
'{str(date_ini_camp)}'
,
f
'{str(date_fin_camp)}'
,
f
'{str(time_ini_camp)}'
,
f
'{str(time_fin_camp)}'
,
f
'{camp_status}'
,
f
'{camp_id_search}'
))
#Conectar al CC2 para insertar datos en la la campaña
callcenter
=
Callcenter
(
api_key
,
cc_url
)
#id_campaign= 87 #Modificar por el valor ingresado
response
=
callcenter
.
search_campaing
(
camp_id_search
)
data
=
response
.
json
()[
'id'
]
insert
=
callcenter
.
insert_number_campaing
(
data
,
campaign_fields
,
campaign_data
)
print
(
insert
)
data_response
=
json
.
loads
(
insert
)[
"status"
]
db_cc
.
cerrar
()
#return jsonify({{payload}}), 200
#return jsonify({"mensaje": f"Camp Ingreso Datos: {camp_data_input} Camp Resultado: {camp_data_search} Comparacion: {result} Resgistros: {payload}"}), 200
return
jsonify
({
"mensaje"
:
f
"Encontrado Campaing ,ID: {camp_id_search} Name: {camp_name_search} Status: {camp_status_search} Fecha Comienzo: {camp_datetime_init_search} Hora Comienzo: {camp_daytime_init_search} Fecha Fin: {camp_datetime_end_search} Hora Fin: {camp_daytime_end_search} Queue: {camp_queue_search} Responce: {data_response}! Validar Registros de Ingreso"
}),
200
else
:
callcenter
=
Callcenter
(
api_key
,
cc_url
)
cread_camp
=
callcenter
.
created_campaing
(
camp_name
,
date_ini_camp
,
time_ini_camp
,
date_fin_camp
,
time_fin_camp
,
campaign_queue
,
camp_obsv
)
print
(
cread_camp
)
return
jsonify
({
"mensaje"
:
f
"No Encontrado Campaing , {camp_name}! Se debe crear una campaña"
}),
401
@
app
.
route
(
'/Consult_Campaign'
,
methods
=
[
'GET'
])
@
jwt_required
()
def
Consult_Campaign
():
usuario
=
get_jwt_identity
()
db
=
MySQLDatabase
(
host
=
db_host
,
user
=
db_user
,
password
=
""
,
database
=
db_name_hiper_service
)
nuevo_id
=
db
.
insertar
(
"INSERT INTO hiper_service_accesos (usuario, token ,fecha_hora, status, message) VALUES (
%
s,
%
s,
%
s,
%
s,
%
s)"
,(
f
'{usuario}'
,
''
,
f
'{fecha_hora}'
,
'Consult Campaing'
,
'Access'
))
db
.
cerrar
()
request_data
=
request
.
get_json
()
dataCollection
=
request_data
[
"dataCollection"
]
campaign_id
=
request_data
[
"id_campaign"
]
campaign_date_ini
=
request_data
[
"date_in"
]
campaign_date_fin
=
request_data
[
"date_out"
]
#Buscar Campaña
callcenter
=
Callcenter
(
api_key
,
cc_url
)
consult_calls
=
callcenter
.
consult_campaing
(
campaign_id
,
campaign_date_ini
,
campaign_date_fin
)
data_response
=
json
.
loads
(
consult_calls
)[
"hydra:member"
]
print
(
data_response
)
#raw_json = data_response[0]
#return jsonify({"mensaje": f"Datos Ingresados , {dataCollection} ;{campaign_id};{campaign_date_ini};{campaign_date_fin}"}), 401
return
jsonify
(
f
"{data_response}"
,
200
)
@
jwt
.
expired_token_loader
def
token_caducado
(
header
,
payload
):
return
jsonify
({
"error"
:
"El token ha caducado. Inicia sesión nuevamente."
}),
401
@
jwt
.
unauthorized_loader
def
token_no_proporcionado
(
callback
):
return
jsonify
({
"error"
:
"Acceso denegado. No se proporcionó un token."
}),
401
@
jwt
.
invalid_token_loader
def
token_invalido
(
error
):
return
jsonify
({
"error"
:
"El token proporcionado es inválido o está mal formado."
}),
401
@
jwt
.
needs_fresh_token_loader
def
token_no_fresco
():
return
jsonify
({
"error"
:
"Se requiere un token fresco para esta operación."
}),
401
@
app
.
route
(
'/prueba'
,
methods
=
[
'POST'
])
def
acceso
():
headers
=
request
.
headers
auth
=
headers
.
get
(
"Authorization"
)
if
auth
==
'Bearer cGJ4OnMzWFRnM0hTQ1Y1R'
:
request_data
=
request
.
get_json
()
if
'dataCollection'
in
request_data
:
data_collection
=
request_data
[
'dataCollection'
]
return
jsonify
({
"message"
:
"DataCollection: data_collection"
}),
200
else
:
return
jsonify
({
"message"
:
"DataCollection: Not Found"
}),
401
else
:
return
jsonify
({
"message"
:
"ERROR: Unauthorized"
}),
401
# if auth == 'Bearer cGJ4OnMzWFRnM0hTQ1Y1R':
# request_data = request.get_json()
# if 'dataCollection' in request_data:
# data_collection = request_data['dataCollection']
#
# if (data_collection=='crm_insert_campaing'):
# id_campaign = request_data['id_campaign']
# fields = request_data['fields']
# data = request_data['data']
# #return jsonify({"message": "OK: Authorized"}), 200
# return jsonify({"message": "OK: data_collection"}), 200
# else:
# return 'Invalid Data Coellections'
# else:
# return jsonify({"message": "ERROR: Unauthorized"}), 401
#return auth
if
__name__
==
'__main__'
:
app
.
run
(
debug
=
True
,
host
=
'0.0.0.0'
)
functions.py
View file @
27792f80
...
@@ -121,112 +121,67 @@ def validate_keys(data):
...
@@ -121,112 +121,67 @@ def validate_keys(data):
def
find_name_position
(
name
):
def
find_name_position
(
name
):
dictionary
=
{
dictionary
=
{
"2000"
:
"Benenaula Choco Margoth Elizabeth"
,
"2017"
:
"Paucar Tapia Dennis Andres"
,
"2001"
:
"Campoverde Samaniego Bryan Andres"
,
"2018"
:
"Hurtado Tocache Mayra Biviana"
,
"2002"
:
"Contreras Guillermo Laura Fernanda"
,
"2019"
:
"Bermeo Cajamarca Tania Marcela "
,
"2003"
:
"Cuenca Sanchez Carmen Maria"
,
"2020"
:
"Sojos Bermeo Lourdes Maricela"
,
"2004"
:
"Granados Tomala Ileana Gabriela"
,
"2021"
:
"Robles Guerra Jhoanna Maricela"
,
"2005"
:
"Guissella Alejandrina Ortega Alvarez"
,
"2022"
:
"Ortega Leon Maria Daniela"
,
"2006"
:
"Henry Esteban Urdiales Landy"
,
"2023"
:
"Peralta Jaramillo Michelle Catalina"
,
"2007"
:
"Jaramillo Calle Josseline Cristina"
,
"2024"
:
"Zambrano Santiak Maria Dolores "
,
"2008"
:
"Maza Guaman Rosa Salome"
,
"2025"
:
"Bravo Andrade Willy Luis"
,
"2009"
:
"Jhon Byron Paula Calle"
,
"2026"
:
"Barbecho Arias Alba Janneth"
,
"2010"
:
"Rodriguez Pena Andrea Del Cisne"
,
"2027"
:
"Calderon Sucuzhanay Eliza Katherine"
,
"2011"
:
"Santiago Sebastian Carpio Aviles"
,
"2028"
:
"Jara Caceres Virginia Carolina"
,
"2012"
:
"Vera Luzuriaga Viviana Carolina"
,
"2030"
:
"Sanchez Zhagnay Angel Marcelo"
,
"2013"
:
"Tapia Yunga Jaime Adrian"
,
"2031"
:
"Gomez Ochoa Cristian Gabriel"
,
"2014"
:
"Godoy Zambrano Katiusca"
,
"2032"
:
"Leon Duenas Valeria Estefania "
,
"2015"
:
"Alexandra Estefania Villa Torres"
,
"2033"
:
"Cardenas Torres Madelyne Coraima"
,
"2016"
:
"Delgado Baque Gabriela Elizabeth"
,
"2034"
:
"Samaniego Gonzaga Camila Nicole "
,
"2017"
:
"Paucar Tapia Dennis Andres"
,
"2035"
:
"Suarez Bacuilima Andres Santiago"
,
"2018"
:
"Hurtado Tocache Mayra Biviana"
,
"2037"
:
"Tapia Penaloza Andreina De Los Angeles"
,
"2019"
:
"Bermeo Cajamarca Tania Marcela"
,
"2038"
:
"Flores Lopez Christian Nicolas "
,
"2020"
:
"Sojos Bermeo Lourdes Maricela"
,
"2040"
:
"Faican Vasquez Jennifer Eliana"
,
"2021"
:
"Robles Guerra Jhoanna Maricela"
,
"2041"
:
"Villa Torres Joseline Andrea "
,
"2022"
:
"Ortega Leon Maria Daniela"
,
"2042"
:
"Penafiel Rodas Karen Salome "
,
"2023"
:
"Peralta Jaramillo Michelle Catalina"
,
"2043"
:
"Jaramillo Gonzaga Evelin Lizbeth "
,
"2024"
:
"Zambrano Santiak Maria Dolores"
,
"2044"
:
"Gabriela Elizabeth Ochoa Fajardo"
,
"2025"
:
"Bravo Andrade Willy Luis"
,
"2045"
:
"Christopher Brian Chang Tapia"
,
"2026"
:
"Barbecho Arias Alba Janneth"
,
"2046"
:
"Maria Guadalupe Arias Asmal"
,
"2027"
:
"Calderon Sucuzhanay Eliza Katherine"
,
"2047"
:
"Christian Adrian Lopez Durazno"
,
"2028"
:
"Jara Caceres Virginia Carolina"
,
"2050"
:
"Matute Segarra Miriam Viviana "
,
"2029"
:
"Vintimilla Vasconez Maria Angelica"
,
"2051"
:
"Arevalo Jara Gabriela Alexandra"
,
"2030"
:
"Sanchez Zhagnay Angel Marcelo"
,
"2052"
:
"Araujo Segovia Erika Patricia"
,
"2031"
:
"Gomez Ochoa Cristian Gabriel"
,
"2053"
:
"Cabrera Arteaga Andreina Estefania"
,
"2032"
:
"Leon Duenas Valeria Estefania"
,
"2054"
:
"Caguana Laime Jhoanna Maribel"
,
"2033"
:
"Cardenas Torres Madelyne Coraima"
,
"2055"
:
"Crespo Pizarro Paola Fernanda"
,
"2034"
:
"Samaniego Gonzaga Camila Nicole"
,
"2056"
:
"Esparza Ayala Pablo Andres"
,
"2035"
:
"Suarez Bacuilima Andres Santiago"
,
"2057"
:
"Espana Marcia"
,
"2036"
:
"Marin Auquilla Rodrigo Fernando"
,
"2058"
:
"Mendoza Avila Andres Fabricio"
,
"2037"
:
"Tapia Penaloza Andreina De Los Angeles"
,
"2059"
:
"Naula Cardenas Paola Cecibel"
,
"2038"
:
"Flores Lopez Christian Nicolas"
,
"2060"
:
"Nieto Guerrero Rolando Estuardo"
,
"2039"
:
"Sarmiento Verdugo Diana Patricia"
,
"2061"
:
"Ordonez Plaza Arturo Xavier"
,
"2040"
:
"Faican Vasquez Jennifer Eliana"
,
"2062"
:
"Parra Reyes Andres Remigio"
,
"2041"
:
"Villa Torres Joseline Andrea"
,
"2063"
:
"Ramon Rodas Katherine Fernanda"
,
"2042"
:
"Penafiel Rodas Karen Salome"
,
"2064"
:
"Rodriguez Rodriguez Paul Esteban"
,
"2043"
:
"Jaramillo Gonzaga Evelin Lizbeth"
,
"2065"
:
"Romero Calero Stefania Magdalena"
,
"2044"
:
"Gabriela Elizabeth Ochoa Fajardo"
,
"2066"
:
"Tenezaca Maza Adriana Nube"
,
"2045"
:
"Christopher Brian Chang Tapia"
,
"2067"
:
"Uzhca Gonzalez Jessica Karina"
,
"2046"
:
"Maria Guadalupe Arias Asmal"
,
"2068"
:
"Velez Arcentales Jenny Isabel"
,
"2047"
:
"Christian Adrian Lopez Durazno"
,
"2069"
:
"Yanez Arevalo Maria Belen"
,
"2048"
:
"Buncay Dutan Natalia Gabriela"
,
"2070"
:
"Baculima Bueno Jessica Priscila"
,
"2049"
:
"Francisco Javier Arevalo Rosas"
,
"2071"
:
"Bermeo Zuna Diego Alejandro"
,
"2050"
:
"Matute Segarra Miriam Viviana"
,
"2072"
:
"Carchi Ordonez Gabriela Elizabeth"
,
"2051"
:
"Arevalo Jara Gabriela Alexandra"
,
"2073"
:
"Lata Sinchi Ana Lucia"
,
"2052"
:
"Araujo Segovia Erika Patricia"
,
"2074"
:
"Maita Robles John Christian"
,
"2053"
:
"Cabrera Arteaga Andreina Estefania"
,
"2075"
:
"Mejia Lojano Gloria Beatriz"
,
"2054"
:
"Caguana Laime Jhoanna Maribel"
,
"2076"
:
"Morales Figueroa Miriam Susana"
,
"2055"
:
"Crespo Pizarro Paola Fernanda"
,
"2077"
:
"Murillo Pinos Ana Lucia"
,
"2056"
:
"Esparza Ayala Pablo Andres"
,
"2078"
:
"Romero Carpio Joseline Lorena"
,
"2057"
:
"Espana Marcia"
,
"2079"
:
"Ulloa Vintimilla Hernan Marcelo"
,
"2058"
:
"Mendoza Avila Andres Fabricio"
,
"2080"
:
"Valdivieso Aviles Jessica Daniela"
,
"2059"
:
"Naula Cardenas Paola Cecibel"
,
"2081"
:
"Vasquez Sari Tatiana Cecibel"
,
"2060"
:
"Nieto Guerrero Rolando Estuardo"
,
"2082"
:
"Vivar Rivadeneira Susana Elizabeth"
"2061"
:
"Ordonez Plaza Arturo Xavier"
,
"2062"
:
"Parra Reyes Andres Remigio"
,
"2063"
:
"Ramon Rodas Katherine Fernanda"
,
"2064"
:
"Rodriguez Rodriguez Paul Esteban"
,
"2065"
:
"Romero Calero Stefania Magdalena"
,
"2066"
:
"Tenezaca Maza Adriana Nube"
,
"2067"
:
"Uzhca Gonzalez Jessica Karina"
,
"2068"
:
"Velez Arcentales Jenny Isabel"
,
"2069"
:
"Yanez Arevalo Maria Belen"
,
"2070"
:
"Baculima Bueno Jessica Priscila"
,
"2071"
:
"Bermeo Zuna Diego Alejandro"
,
"2072"
:
"Carchi Ordonez Gabriela Elizabeth"
,
"2073"
:
"Lata Sinchi Ana Lucia"
,
"2074"
:
"Maita Robles John Christian"
,
"2075"
:
"Mejia Lojano Gloria Beatriz"
,
"2076"
:
"Morales Figueroa Miriam Susana"
,
"2077"
:
"Murillo Pinos Ana Lucia"
,
"2078"
:
"Romero Carpio Joseline Lorena"
,
"2079"
:
"Ulloa Vintimilla Hernan Marcelo"
,
"2080"
:
"Valdivieso Aviles Jessica Daniela"
,
"2081"
:
"Vasquez Sari Tatiana Cecibel"
,
"2082"
:
"Vivar Rivadeneira Susana Elizabeth"
,
"2083"
:
"Barrera Barrera Edgar Lizandro"
,
"2084"
:
"Gonzalez Gonzalez Wilmer David"
,
"2085"
:
"Guaman Bazan Blanca Gladys"
,
"2086"
:
"Guaman Fernandez Mercy Gabriela"
,
"2087"
:
"Gutierrez Calle Maricela Janeth"
,
"2088"
:
"Munoz Perez Carmen Gardenia"
,
"2089"
:
"Piedra Piedra Martha Cecila"
,
"2090"
:
"Tobar Cruz Alisson Joan"
,
"2091"
:
"Ulloa Yunga Martha Lucia"
,
"2092"
:
"Pillajo Vanegas Jorge Luis"
,
"2093"
:
"Velez Montenegro Nohemy Veronica"
,
"2094"
:
"Tandazo Hernandez Estefania"
,
"2095"
:
"Byron Lopez"
,
"2096"
:
"Greta Andrade"
,
"2097"
:
"Janeth Mendez"
,
"2098"
:
"Maria Elena Cardenas"
,
"2099"
:
"Byron Benavides"
,
"2100"
:
"Katerine Pauzhi"
,
"2101"
:
"Andrea Guanuchi"
,
"2102"
:
"Paul Carpio"
,
"2103"
:
"Maria Belen Ochoa"
,
"2104"
:
"Christian Cando"
,
"2105"
:
"Marcimex Jhon Byron Paula Calle"
}
}
for
key
,
value
in
dictionary
.
items
():
for
key
,
value
in
dictionary
.
items
():
if
value
==
name
:
if
value
==
name
:
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment