PEP8 and default configuration

This commit is contained in:
Denis Zheleztsov 2017-09-04 12:37:09 +03:00
parent a80042a384
commit 09a271b5c5
2 changed files with 22 additions and 23 deletions

View File

@ -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"
}

View File

@ -9,45 +9,49 @@ import requests
def action(name, method, data=None):
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'
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'
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:
@ -58,6 +62,3 @@ def panel(request):
my_status = action('status', 'get')
print '3'
return render(request, 'rbmd/index.html', {'ws': ws, 'metrics': metrics, 'status': my_status})