change to yaml
This commit is contained in:
parent
ef2a71b617
commit
ec83aba3bc
@ -1,25 +1,32 @@
|
||||
import os
|
||||
|
||||
from django.conf import settings
|
||||
from rest_framework.views import APIView
|
||||
from rest_framework.response import Response
|
||||
import yaml
|
||||
|
||||
from .utils import IniParser, SystemStats, get_media_path
|
||||
from django.conf import settings
|
||||
from rest_framework.response import Response
|
||||
from rest_framework.views import APIView
|
||||
from rest_framework.permissions import AllowAny
|
||||
|
||||
from .utils import SystemStats, get_media_path
|
||||
|
||||
|
||||
def read_config(path):
|
||||
with open(path, 'r') as config_file:
|
||||
return yaml.safe_load(config_file)
|
||||
|
||||
|
||||
class Config(APIView):
|
||||
permission_classes = (AllowAny,)
|
||||
"""
|
||||
read and write config from ffplayout engine
|
||||
for reading, endpoint is: http://127.0.0.1:8000/api/config/?config
|
||||
for reading endpoint is: http://127.0.0.1:8000/api/config/?config
|
||||
"""
|
||||
|
||||
def get(self, request, *args, **kwargs):
|
||||
if 'config' in request.GET.dict():
|
||||
if os.path.isfile(settings.FFPLAYOUT_CONFIG):
|
||||
parser = IniParser()
|
||||
parser.read(settings.FFPLAYOUT_CONFIG)
|
||||
|
||||
return Response(parser.as_dict())
|
||||
yaml = read_config(settings.FFPLAYOUT_CONFIG)
|
||||
return Response(yaml)
|
||||
else:
|
||||
return Response({
|
||||
"success": False,
|
||||
@ -27,6 +34,15 @@ class Config(APIView):
|
||||
else:
|
||||
return Response({"success": False})
|
||||
|
||||
def post(self, request, *args, **kwargs):
|
||||
if 'config' in request.POST.dict():
|
||||
pass
|
||||
print(request.query_params)
|
||||
print(args)
|
||||
print(kwargs)
|
||||
|
||||
return Response({"success": False})
|
||||
|
||||
|
||||
class Statistics(APIView):
|
||||
"""
|
||||
|
@ -153,7 +153,7 @@ USE_TZ = True
|
||||
STATIC_URL = '/static/'
|
||||
|
||||
# path to ffplayout engine config
|
||||
FFPLAYOUT_CONFIG = '/etc/ffplayout/ffplayout.conf'
|
||||
FFPLAYOUT_CONFIG = '/etc/ffplayout/ffplayout.yml'
|
||||
|
||||
# used network interface for statistics: eth0, eno1, etc.
|
||||
NET_INTERFACE = 'br0'
|
||||
|
Loading…
Reference in New Issue
Block a user