28 lines
942 B
Python
28 lines
942 B
Python
import subprocess
|
|
from flask import Flask, render_template
|
|
|
|
app = Flask(__name__)
|
|
|
|
@app.route('/')
|
|
def scan_wifi_networks():
|
|
try:
|
|
result = subprocess.run(['sudo', 'iwlist', 'wlan0', 'scan'], capture_output=True, text=True)
|
|
networks = parse_iwlist_output(result.stdout)
|
|
return networks # 이 부분이 Wi-Fi 목록을 반환하도록 보장해야 함
|
|
except Exception as e:
|
|
print(f"Error scanning Wi-Fi networks: {e}")
|
|
return [] # 오류가 발생하면 빈 리스트 반환
|
|
|
|
def parse_iwlist_output(output):
|
|
# 여기에 iwlist 출력을 파싱하여 네트워크 리스트를 생성하는 코드를 추가합니다.
|
|
# 예: 네트워크 이름 (ESSID) 및 기타 세부 정보를 추출합니다.
|
|
pass
|
|
|
|
def index():
|
|
networks = scan_wifi_networks()
|
|
return render_template('index.html', networks=networks)
|
|
|
|
if __name__ == '__main__':
|
|
app.run(debug=True, host='0.0.0.0')
|
|
|