This commit is contained in:
Hendrik Borras 2018-01-30 14:14:58 +01:00
parent 3ac748add8
commit e60ab280b7
2 changed files with 2 additions and 36 deletions

View file

@ -52,27 +52,6 @@
</div>
</div>
<div class="col-lg-6">
<div class="panel panel-default">
<div class="panel-heading">
Contact address
</div>
<!-- /.panel-heading -->
<div class="panel-body">
Currently saved e-mail address: <b>{{ current_email }}</b> <br/>
<br/>
Please insert your E-Mail address before connecting to any WiFi. The CosmicPi will contact you under this address, once it has connected.
Your E-Mail will not be used in any other context, other than helping you setup the CosmicPi. Your address will be deleted on reboot.
<form method="get" action="/settings">
<label>E-Mail
<input type="text" name="email" value=""><br/>
</label>
<button type="submit">Save!</button>
</form>
</div>
</div>
</div>
<br>

View file

@ -35,9 +35,6 @@ UI_PASS = config.get("UI", "password")
DEFAULT_WIFI_NAME = config.get("Default WiFi", "name")
DEFAULT_WIFI_PASS = config.get("Default WiFi", "password")
WPA_SUPPLICANT_LOCATION = str(config.get("MISC", "wpa_supplicant_location"))
global_user_address = ''
GMAIL_USER = "cosmicpidevice@gmail.com"
GMAIL_PW = 'meineguete'
# start flask
app = Flask(__name__)
@ -159,12 +156,8 @@ def plotting_page():
@app.route('/settings/', methods=['GET', 'POST'])
@basic_auth.required
def settings_page():
email = request.args.get('email')
global global_user_address
if not email == None:
global_user_address = email
current_WiFi, avail_WiFi = get_current_and_available_networks()
return render_template('settings.html', available_wifis=avail_WiFi, current_wifi=current_WiFi, current_email=global_user_address)
return render_template('settings.html', available_wifis=avail_WiFi, current_wifi=current_WiFi)
def get_current_and_available_networks():
wifiNetworkList = ''
@ -177,7 +170,7 @@ def get_current_and_available_networks():
print(e)
except WindowsError as e:
print("Well, windows just can't do this...")
connectedNetworkNameResponse = '"maybe a windows network?"'
connectedNetworkNameResponse = '"No networks found, because the WebUI is beeing executed on windows."'
connectedNetworkNameStr = re.findall('\"(.*?)\"', connectedNetworkNameResponse) #" Find the string between quotes
if len(connectedNetworkNameStr) < 1:
connectedNetworkNameStr = ''
@ -210,17 +203,11 @@ def wifi_connector():
wifi_name = request.args.get('selected_wifi')
wifi_pw = request.args.get('password')
# check that the user has given a mail address
global global_user_address
if global_user_address == "":
return 'Please save an e-mail address before connecting to any other WiFi! <a href="/settings/">Go back to the settings page</a>'
# launch the wifi login in a different thread
# we need to to it like this, since otherwise the user would never recieve an answer...
thread.start_new_thread(connect_to_wifi, (wifi_name, wifi_pw))
msg = 'The CosmicPi will now try to connect to the WiFi "{}". '.format(wifi_name)
msg += "When the CosmicPi has connected to the internet you will receive an e-mail. "
msg += "If no internet connection is found or the connection was not sucessfull the CosmiPi will recreate the WiFi hotspot. Please wait at least two minutes."
return msg