



"""simple docstring"""




import requests

try:
	from django.contrib.auth import authenticate, login
	from django.shortcuts import redirect, render
except ImportError:
	UpperCAmelCase				:							str								=print



def 				_lowerCAmelCase      (_lowerCAmelCase):
					UpperCamelCase_											=				"secretKey"
					UpperCamelCase_											=				"https://www.google.com/recaptcha/api/siteverify"

					# when method is not POST, direct user to login page
					if request.method != "POST":
										return render(lowercase_				,		"login.html")

					# from the frontend, get username, password, and client_key
					UpperCamelCase_											=				request.POST.get("username")
					UpperCamelCase_											=				request.POST.get("password")
					UpperCamelCase_											=				request.POST.get("g-recaptcha-response")

					# post recaptcha response to Google's recaptcha api
					UpperCamelCase_											=				requests.post(lowercase_				,		data={"secret": secret_key, "response": client_key})
					# if the recaptcha api verified our keys
					if response.json().get("success"				,		lowercase_):
										# authenticate the user
										UpperCamelCase_											=				authenticate(lowercase_				,		username=lowercase_				,		password=lowercase_)
										if user_in_database:
															login(lowercase_				,		lowercase_)
															return redirect("/your-webpage")
					return render(lowercase_				,		"login.html")





def 				_lowerCAmelCase      (_lowerCAmelCase				,		_lowerCAmelCase):
					UpperCamelCase_											=				0
					for ele in arr:
										total_sum += product_sum(_lowerCAmelCase				,		depth + 1) if isinstance(_lowerCAmelCase				,		_lowerCAmelCase) else ele
					return total_sum * depth



def 				_lowerCAmelCase      (_lowerCAmelCase):
					return product_sum(_lowerCAmelCase				,		1)


if __name__ == "__main__":
	import doctest

	doctest.testmod()
