Spaces:
Runtime error
Runtime error
File size: 824 Bytes
3a63794 5f0ed21 3a63794 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
from services.api_service import get_data, post_data, delete_data
# Forward query params
def get_fw_query_params(fw_option: str):
if fw_option == 'none':
return ''
if fw_option == 'auto':
return '?fw=auto'
else:
return '?fw=' + fw_option
def fetch_fw_options(to_list=False) -> dict:
response = get_data("/service/fw/")
if to_list:
return [option['url'] for option in response['fw']]
fw_servers = {}
for res in response['fw']:
fw_servers[res['url']] = res['tasks'] / 100
return fw_servers
def add_fw_option(url: str):
request_data = {
"url": url
}
post_data("/service/fw/", json=request_data)
def del_fw_option(index: int):
request_data = {
"index": index
}
delete_data("/service/fw/", json=request_data)
|