def initial_setup(): form = initialSetupForm() if request.method == "GET": return render_template("initial_setup.html", form=form) elif request.method == "POST": if form.validate(): ssid = form.ssid.data.rsplit("-", 1)[0] psk = form.psk.data add_wifi(ssid, psk) if internet_status() is True: vpn_server = form.vpn_server.data user_id = form.user_id.data user_psk = form.user_psk.data set_vpn_params(vpn_server, user_id, user_psk) restart_vpn() flash("Wifi and VPN settings saved!", "success") return redirect(url_for("status")) else: flash("Error! Cannot reach the internet...", "error") return render_template("initial_setup.html", form=form) else: flash("Error! " + str(form.data), "error") return render_template("initial_setup.html", form=form)
def initial_setup(): form = initialSetupForm() if(request.method == "GET"): return render_template("initial_setup.html", form=form) elif(request.method == "POST"): if(form.validate()): ssid = (form.ssid.data).rsplit("-", 1)[0] psk = form.psk.data add_wifi(ssid, psk) if(internet_status() == True): vpn_server = form.vpn_server.data user_id = form.user_id.data user_psk = form.user_psk.data set_vpn_params(vpn_server, user_id, user_psk) restart_vpn() flash("Wifi and VPN settings saved!", "success") return redirect(url_for("status")) else: flash("Error! Cannot reach the internet...", "error") return render_template("initial_setup.html", form=form) else: flash("Error! " + str(form.data), "error") return render_template("initial_setup.html", form=form)
def vpn_psk(): form = vpnPskForm() if request.method == "GET": return render_template("vpn_psk.html", form=form) elif request.method == "POST": if form.validate(): vpn_server = form.vpn_server.data user_id = form.user_id.data user_psk = form.user_psk.data set_vpn_params(vpn_server, user_id, user_psk) restart_vpn() if vpn_status(): flash("VPN settings saved and VPN restarted!", "success") return redirect(url_for("status")) else: flash( "VPN settings saved and VPN restarted! Unable to establish VPN connection.", "error") return render_template("vpn_psk.html", form=form) else: flash("Error! " + str(form.data), "error") return render_template("vpn_psk.html", form=form)
def api_vpn_credentials(): if request.method == "POST": form = initialSetupForm() form.vpn_server.data = request.json["vpn_server"] form.user_id.data = request.json["user_id"] form.user_psk.data = request.json["user_psk"] if request.headers['Content-Type'] == 'application/json': if form.vpn_server.validate(form) and form.user_id.validate(form) and form.user_psk.validate(form): set_vpn_params(form.vpn_server.data, form.user_id.data, form.user_psk.data) return "Successfully set vpn_server, user_id, and psk for VPN" else: return "Invalid user_id or psk format" else: return "415 Unsupported Media Type - Use application/json" elif request.method == "DELETE": reset_vpn_params() return "Successfully reset vpn_server, user_id, and psk for VPN" else: return "Only POST and DELETE methods are supported. Refer to the API Documentation"
def api_vpn_credentials(): if(request.method == "POST"): form = initialSetupForm() form.vpn_server.data = request.json["vpn_server"] form.user_id.data = request.json["user_id"] form.user_psk.data = request.json["user_psk"] if(request.headers['Content-Type'] == 'application/json'): if(form.vpn_server.validate(form) and form.user_id.validate(form) and form.user_psk.validate(form)): set_vpn_params(form.vpn_server.data, form.user_id.data, form.user_psk.data) return "Successfully set vpn_server, user_id, and psk for VPN" else: return "Invalid user_id or psk format" else: return "415 Unsupported Media Type - Use application/json" elif(request.method == "DELETE"): reset_vpn_params() return "Successfully reset vpn_server, user_id, and psk for VPN" else: return "Only POST and DELETE methods are supported. Refer to the API Documentation"
def vpn_psk(): form = vpnPskForm() if(request.method == "GET"): return render_template("vpn_psk.html", form=form) elif(request.method == "POST"): if(form.validate()): vpn_server = form.vpn_server.data user_id = form.user_id.data user_psk = form.user_psk.data set_vpn_params(vpn_server, user_id, user_psk) restart_vpn() if(vpn_status()): flash("VPN settings saved and VPN restarted!", "success") return redirect(url_for("status")) else: flash("VPN settings saved and VPN restarted! Unable to establish VPN connection.", "error") return render_template("vpn_psk.html", form=form) else: flash("Error! " + str(form.data), "error") return render_template("vpn_psk.html", form=form)