作业---修改haproxy配置文件

时间:2023-03-08 17:43:11
作业---修改haproxy配置文件
#查询
f=open("C:\\aaaaaaaaaaaaa\\haproxy.txt", "r", encoding="utf-8")
haproxy_list = f.readlines()
website_address = input("请输入要查询的网址:")
website_address = "backend " + website_address
lenth=len(haproxy_list)
#print(website_address)
i=0
j=1
for line in haproxy_list:
if website_address in line and line.startswith("backend"):
print(haproxy_list[i])
j=i+1
while "backend" not in haproxy_list[j] :
print(haproxy_list[j])
j+=1
if j >= lenth:
break
elif j == lenth and i == lenth:
print("你输入的内容查询不到")
i+=1
if i == lenth and j==1:
print("你输入的内容查询不到")
f.close()