def execute_action(): action = request.form["action"] if action == "reboot": pi_reboot() elif action == "shutdown": pi_shutdown() elif action == "start_vpn": start_vpn() flash("VPN Started!", "notice") elif action == "stop_vpn": stop_vpn() flash("VPN Stopped!", "notice") elif action == "restart_vpn": restart_vpn() flash("VPN Restarted!", "notice") elif action == "ssh_service": start_ssh_service() flash("SSH Service Started! It will be turned off on reboot.") elif action == "update_client": update_client() flash("Client will reboot... please reload this page in 1 minute.") else: form = initialSetupForm() flash("Error! Invalid Action!", "error") return redirect(url_for("status"))
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 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 execute_action(): action = request.form["action"] if(action == "reboot"): pi_reboot() elif(action == "shutdown"): pi_shutdown() elif(action == "start_vpn"): start_vpn() flash("VPN Started!", "notice") elif(action == "stop_vpn"): stop_vpn() flash("VPN Stopped!", "notice") elif(action == "restart_vpn"): restart_vpn() flash("VPN Restarted!", "notice") elif(action == "ssh_service"): start_ssh_service() flash("SSH Service Started! It will be turned off on reboot.") else: form = initialSetupForm() flash("Error! Invalid Action!", "error") return redirect(url_for("status"))