mirror of
https://github.com/Dispatcharr/Dispatcharr.git
synced 2026-01-23 02:35:14 +00:00
new environment settings endpoint, added added in support for conditionally building video URL since we don't want dev env to proxy the stream through the react server
This commit is contained in:
parent
ca676206a4
commit
412b799d7b
10 changed files with 174 additions and 66 deletions
|
|
@ -6,6 +6,10 @@ from django.shortcuts import get_object_or_404
|
|||
from .models import UserAgent, StreamProfile, CoreSettings
|
||||
from .serializers import UserAgentSerializer, StreamProfileSerializer, CoreSettingsSerializer
|
||||
from rest_framework.permissions import IsAuthenticated
|
||||
from rest_framework.decorators import api_view, permission_classes
|
||||
from drf_yasg.utils import swagger_auto_schema
|
||||
import requests
|
||||
import os
|
||||
|
||||
class UserAgentViewSet(viewsets.ModelViewSet):
|
||||
"""
|
||||
|
|
@ -28,3 +32,24 @@ class CoreSettingsViewSet(viewsets.ModelViewSet):
|
|||
"""
|
||||
queryset = CoreSettings.objects.all()
|
||||
serializer_class = CoreSettingsSerializer
|
||||
|
||||
@swagger_auto_schema(
|
||||
method='get',
|
||||
operation_description="Endpoint for environment details",
|
||||
responses={200: "Environment variables"}
|
||||
)
|
||||
@api_view(['GET'])
|
||||
@permission_classes([IsAuthenticated])
|
||||
def environment(request):
|
||||
public_ip = None
|
||||
try:
|
||||
response = requests.get("https://api64.ipify.org?format=json")
|
||||
public_ip = response.json().get("ip")
|
||||
except requests.RequestException as e:
|
||||
return f"Error: {e}"
|
||||
|
||||
return Response({
|
||||
'authenticated': True,
|
||||
'public_ip': public_ip,
|
||||
'env_mode': "dev" if os.getenv('DISPATCHARR_ENV', None) == "dev" else "prod",
|
||||
})
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue