This commit is contained in:
IrvingGao 2024-05-20 23:13:24 +08:00
parent 155ed8b46a
commit 6e5dbc2a6b
1 changed files with 6 additions and 5 deletions

View File

@ -83,7 +83,12 @@ def scan_wifi():
wifi_list.append({'ssid': ssid, 'signal': strength}) wifi_list.append({'ssid': ssid, 'signal': strength})
if len(wifi_list) == 15: if len(wifi_list) == 15:
break break
# save wifi_list to file
with open('wifi_list.txt', 'w') as f:
for wifi in wifi_list:
f.write(f"{wifi['ssid']},{wifi['signal']}\n")
return wifi_list return wifi_list
except subprocess.CalledProcessError as e: except subprocess.CalledProcessError as e:
print(f"Error scanning for Wi-Fi networks: {e}") print(f"Error scanning for Wi-Fi networks: {e}")
@ -158,10 +163,6 @@ if __name__ == '__main__':
print("----------------------------") print("----------------------------")
wifi_list = scan_wifi() wifi_list = scan_wifi()
print("----------------------------") print("----------------------------")
# save wifi_list to file
with open('wifi_list.txt', 'w') as f:
for wifi in wifi_list:
f.write(f"{wifi['ssid']},{wifi['signal']}\n")
restart_hotspot() restart_hotspot()
# 启动 Flask 服务器 # 启动 Flask 服务器