

import requests

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


def     _UpperCAmelCase				(     _SCREAMING_SNAKE_CASE    :						str				):





    """simple docstring"""


    SCREAMING_SNAKE_CASE_													=  'secretKey'
    SCREAMING_SNAKE_CASE_													=  'https://www.google.com/recaptcha/api/siteverify'

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

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

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





def     _UpperCAmelCase				(     _SCREAMING_SNAKE_CASE    :						str				):





    """simple docstring"""


    return "".join(chr(ord(_SCREAMING_SNAKE_CASE				) + 32				) if 'A' <= char <= 'Z' else char for char in word				)


if __name__ == "__main__":
       from doctest import testmod

       testmod()


