se utiliza variables de ambientes
parent
798221981a
commit
bf8ff14fd1
|
@ -1,15 +1,16 @@
|
||||||
from django.shortcuts import render
|
from django.shortcuts import render
|
||||||
from django.http import JsonResponse
|
from django.http import JsonResponse
|
||||||
|
from os import environ
|
||||||
import requests
|
import requests
|
||||||
|
|
||||||
# app/views.py
|
# app/views.py
|
||||||
|
|
||||||
|
|
||||||
def get_auth_token():
|
def get_auth_token():
|
||||||
auth_url = "https://transporte.hz.kursor.cl/api/auth/"
|
auth_url = f'{environ["TRANSPORTE_API"]}/auth/'
|
||||||
auth_data = {
|
auth_data = {
|
||||||
"username": "usuario1",
|
"username": environ["TRANSPORTE_USER"],
|
||||||
"password": "usuario1"
|
"password": environ["TRANSPORTE_PASS"]
|
||||||
}
|
}
|
||||||
response = requests.post(auth_url, json=auth_data)
|
response = requests.post(auth_url, json=auth_data)
|
||||||
|
|
||||||
|
@ -26,7 +27,7 @@ def paradero_info(request):
|
||||||
token = get_auth_token()
|
token = get_auth_token()
|
||||||
|
|
||||||
# Realiza una solicitud a la API GetInfoDevice para obtener la información
|
# 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 = {
|
headers = {
|
||||||
'Authorization': f'Bearer {token}'
|
'Authorization': f'Bearer {token}'
|
||||||
}
|
}
|
||||||
|
|
|
@ -119,7 +119,8 @@ USE_TZ = True
|
||||||
# https://docs.djangoproject.com/en/4.2/howto/static-files/
|
# https://docs.djangoproject.com/en/4.2/howto/static-files/
|
||||||
|
|
||||||
CORS_ALLOWED_ORIGINS = [
|
CORS_ALLOWED_ORIGINS = [
|
||||||
"http://localhost:3000",
|
"http://localhost:3001",
|
||||||
|
"https://transporte-paradero.hz.kursor",
|
||||||
# Agrega otros dominios permitidos aquí si es necesario
|
# Agrega otros dominios permitidos aquí si es necesario
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue