(request: WSGIRequest)
Connect to a given ssid with the given password.
Connect to a given ssid with the given password.
Connect to a given ssid with the given password .
def connect_to_wifi(request: WSGIRequest) -> HttpResponse:
    """Connect to a given ssid with the given password."""
    ssid = request.POST.get("ssid")
    password = request.POST.get("password")
    if ssid is None or password is None or ssid == "" or password == "":
        return HttpResponseBadRequest("Please provide both SSID and password")
    try:
        output = subprocess.check_output(
            ["sudo", "/usr/local/sbin/raveberry/connect_to_wifi", ssid, password]
        ).decode()
        return HttpResponse(output)
    except subprocess.CalledProcessError as e:
        output = e.output.decode()
        return HttpResponseBadRequest(output)
def connect_to_wifi ( request : WSGIRequest ) -> HttpResponse : ssid = request . POST . get ( "ssid" ) password = request . POST . get ( "password" ) if ssid is None or password is None or ssid == "" or password == "" : return HttpResponseBadRequest ( "Please provide both SSID and password" ) try : output = subprocess . check_output ( [ "sudo" , "/usr/local/sbin/raveberry/connect_to_wifi" , ssid , password ] ) . decode ( ) return HttpResponse ( output ) except subprocess . CalledProcessError as e : output = e . output . decode ( ) return HttpResponseBadRequest ( output )