def haproxy_reload(Type=None): form = MyForm.MyForm_Submit() if Type: if Type == 'internet': URL = "http://op.baihe.com/haproxy_conf?type=cw&ip=127.0.0.1:80&domain=test.baihe.com" else: URL = "http://op.baihe.com/haproxy_conf?type=cw&ip=127.0.0.1:80&domain=test.baihe.com&intranet=True" f = requests.get(URL, timeout=10) Info = f.json() if 'result' in f.json(): Info = f.json()['result'] return render_template('qrcode.html', INFO=Info) return render_template('haproxy_reload.html', form=form)
def haproxy_reload(Type=None): form = MyForm.MyForm_Submit() crypto = Md5.crypto(crypto_key) code = choice([x for x in range(100)]) internet = "/haproxy_reload/%s" %crypto.encrypt('internet|%i' %code) intranet = "/haproxy_reload/%s" %crypto.encrypt('intranet|%i' %code) URL = None HA_API = app.config.get('HAPROXY_API') if Type: Type = crypto.decrypt(Type).split('|')[0] if Type == 'internet': URL = "%s?type=cw&ip=127.0.0.1:80&domain=test.baihe.com" %HA_API if Type == 'intranet': URL = "%s?type=cw&ip=127.0.0.1:80&domain=test.baihe.com&intranet=True" %HA_API if URL: f = requests.get(URL,timeout=10,verify=False) Info = f.json() if 'result' in f.json(): Info = f.json()['result'] return render_template('qrcode.html', INFO=Info) return render_template('haproxy_reload.html',Main_Infos=g.main_infos,form=form,internet=internet,intranet=intranet)