.
This commit is contained in:
52
app.py
52
app.py
@@ -1,11 +1,8 @@
|
||||
# sudo nmcli device wifi connect "Home" ifname wlxf81a6719febb password "Dragon1234"
|
||||
# sudo nmcli -t -f SSID,SIGNAL,IN-USE,SECURITY -e yes -m tab device wifi list ifname wlxf81a6719febb --rescan yes
|
||||
|
||||
import subprocess
|
||||
import sys
|
||||
|
||||
from flask import Flask
|
||||
from flask import request
|
||||
from flask import request, redirect
|
||||
|
||||
CMD_SCAN = "sudo nmcli -t -f SSID,SIGNAL,IN-USE,SECURITY -e yes -m tab device wifi list ifname wlxf81a6719febb --rescan yes"
|
||||
scan = ["rpi:100: :WPA2", "Home:94:*:WPA2", "HOME2:48: :WPA2", "BT:23: :"]
|
||||
@@ -13,12 +10,8 @@ scan = ["rpi:100: :WPA2", "Home:94:*:WPA2", "HOME2:48: :WPA2", "BT:23: :"]
|
||||
|
||||
app = Flask(__name__)
|
||||
|
||||
# sudo nmcli device wifi connect "HOME2" ifname wlxf81a6719febb password "Dragon123"
|
||||
# Device 'wlxf81a6719febb' successfully activated with 'ffbc2621-c0d8-4975-8509-92c1740be6a7'.
|
||||
# rich@rpi:~$ echo $?
|
||||
# 0
|
||||
# rich@rpi:~$ sudo nmcli device wifi connect "HOME2" ifname wlxf81a6719febb password "Dragon1234"
|
||||
# Error: Connection activation failed: (7) Secrets were required, but not provided.
|
||||
# sudo nmcli device wifi connect "Home" ifname wlxf81a6719febb password "password"
|
||||
# sudo nmcli -t -f SSID,SIGNAL,IN-USE,SECURITY -e yes -m tab device wifi list ifname wlxf81a6719febb --rescan yes
|
||||
|
||||
|
||||
def scan_wifi():
|
||||
@@ -32,19 +25,30 @@ def scan_wifi():
|
||||
scan.append(line)
|
||||
|
||||
|
||||
# <!DOCTYPE html>
|
||||
# <html>
|
||||
# <body>
|
||||
@app.route("/connect")
|
||||
def connect():
|
||||
return "connect"
|
||||
|
||||
# <h2>Enter Password</h2>
|
||||
|
||||
# <form>
|
||||
# <input type="text" id="passwd" name="passwd" value=""><br>
|
||||
# <p><input type=submit value="Submit"></p>
|
||||
# </form>
|
||||
@app.route("/passwd", methods=["GET", "POST"])
|
||||
def passwd():
|
||||
if request.method == "GET":
|
||||
html = """<!DOCTYPE html>
|
||||
<html>
|
||||
<body>
|
||||
|
||||
# </body>
|
||||
# </html>
|
||||
<h2>Enter Password</h2>
|
||||
|
||||
<form method="POST">
|
||||
<input type="text" id="passwd" name="passwd" value=""><br>
|
||||
<p><input type=submit value="Submit"></p>
|
||||
</form>
|
||||
|
||||
</body>
|
||||
</html>"""
|
||||
return html
|
||||
if request.method == "POST":
|
||||
return redirect("/connect")
|
||||
|
||||
|
||||
@app.route("/", methods=["GET", "POST"])
|
||||
@@ -81,6 +85,12 @@ def main():
|
||||
output = output.replace("*DATA*", table)
|
||||
return output
|
||||
if request.method == "POST":
|
||||
try:
|
||||
line = scan[int(request.form.get("type_radio")) - 1]
|
||||
except:
|
||||
return redirect("/")
|
||||
|
||||
return line
|
||||
if line.split(":")[3] == "WPA2":
|
||||
return redirect("/passwd")
|
||||
|
||||
return redirect("/connect")
|
||||
|
||||
Reference in New Issue
Block a user