diff --git a/rbmd/conf.json b/rbmd/conf.json index 2cc1b22..db6ed6b 100644 --- a/rbmd/conf.json +++ b/rbmd/conf.json @@ -1,6 +1,4 @@ { - -"api": "http://10.8.0.34:9076/v1", -"ws": "ws://php.difrex.ru/ws" - + "api": "http://127.0.0.1:9076/v1", + "ws": "ws://127.0.0.1:7690/ws" } diff --git a/rbmd/views.py b/rbmd/views.py index a87a978..8c3f826 100644 --- a/rbmd/views.py +++ b/rbmd/views.py @@ -9,45 +9,49 @@ import requests def action(name, method, data=None): - - with open('conf.json') as conf: + with open('conf.json') as conf: url = json.load(conf)["api"] + '/' + name - if method == 'get': - print 'start' - try: res = requests.get(url).content - except: res = 'connection can\'t be established' - print 'end' - elif method == 'post': - print data - try: res = requests.post(url, data).content - except: res = 'connection can\'t be established' + if method == 'get': + print 'start' + try: + res = requests.get(url).content + except: + res = 'connection can\'t be established' + print 'end' + elif method == 'post': + print data + try: + res = requests.post(url, data).content + except: + res = 'connection can\'t be established' return res -def get_status(request): +def get_status(request): my_status = action('status', 'get') return JsonResponse(my_status, safe=False) -def mount(request): +def mount(request): if request.method == 'POST': data = request.POST.dict() res = action('mount', 'post', json.dumps(data)) return JsonResponse(res, safe=False) -def unmount(request): +def unmount(request): data = request.GET.dict() res = action('umount', 'post', json.dumps(data)) return JsonResponse(res, safe=False) -def resolve(request): +def resolve(request): data = request.GET.dict() res = action('resolve', 'post', json.dumps(data)) print 'res' + res return JsonResponse(res, safe=False) + @login_required(login_url="/admin/login/?next=/") def panel(request): with open('conf.json') as conf: @@ -57,7 +61,4 @@ def panel(request): print '2' my_status = action('status', 'get') print '3' - return render(request, 'rbmd/index.html', {'ws' : ws, 'metrics' : metrics, 'status' : my_status}) - - - + return render(request, 'rbmd/index.html', {'ws': ws, 'metrics': metrics, 'status': my_status})