1
0
mirror of https://github.com/fHDHR/fHDHR_NextPVR.git synced 2025-12-06 11:26:57 -05:00
fHDHR_NextPVR/fHDHR_web/api/route_list.py
2021-01-08 15:35:55 -05:00

38 lines
1009 B
Python

from flask import Response, request, redirect, session
import urllib.parse
import json
class Route_List():
endpoints = ["/api/routes"]
endpoint_name = "api_routes"
endpoint_methods = ["GET", "POST"]
def __init__(self, fhdhr):
self.fhdhr = fhdhr
def __call__(self, *args):
return self.get(*args)
def get(self, *args):
method = request.args.get('method', default="get", type=str)
redirect_url = request.args.get('redirect', default=None, type=str)
if method == "get":
return_json = json.dumps(session["route_list"], indent=4)
return Response(status=200,
response=return_json,
mimetype='application/json')
else:
return "%s Invalid Method" % method
if redirect_url:
return redirect("%s?retmessage=%s" % (redirect_url, urllib.parse.quote("%s Success" % method)))
else:
return "%s Success" % method