From bf8ff14fd117907b83984133244eece9fe8b3e8d Mon Sep 17 00:00:00 2001 From: Francisco Sandoval Date: Tue, 5 Dec 2023 13:53:31 -0300 Subject: [PATCH] se utiliza variables de ambientes --- app/views.py | 9 +++++---- project/settings.py | 3 ++- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/app/views.py b/app/views.py index 7b27c91..b1c3e3f 100644 --- a/app/views.py +++ b/app/views.py @@ -1,15 +1,16 @@ from django.shortcuts import render from django.http import JsonResponse +from os import environ import requests # app/views.py def get_auth_token(): - auth_url = "https://transporte.hz.kursor.cl/api/auth/" + auth_url = f'{environ["TRANSPORTE_API"]}/auth/' auth_data = { - "username": "usuario1", - "password": "usuario1" + "username": environ["TRANSPORTE_USER"], + "password": environ["TRANSPORTE_PASS"] } response = requests.post(auth_url, json=auth_data) @@ -26,7 +27,7 @@ def paradero_info(request): token = get_auth_token() # Realiza una solicitud a la API GetInfoDevice para obtener la información - api_url = "https://transporte.hz.kursor.cl/api/dispositivos/getInfoDevice/" + api_url = f'{environ["TRANSPORTE_API"]}/dispositivos/getInfoDevice/' headers = { 'Authorization': f'Bearer {token}' } diff --git a/project/settings.py b/project/settings.py index 6886828..a919b91 100644 --- a/project/settings.py +++ b/project/settings.py @@ -119,7 +119,8 @@ USE_TZ = True # https://docs.djangoproject.com/en/4.2/howto/static-files/ CORS_ALLOWED_ORIGINS = [ - "http://localhost:3000", + "http://localhost:3001", + "https://transporte-paradero.hz.kursor", # Agrega otros dominios permitidos aquí si es necesario ]