




'''simple docstring'''

import requests

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




def    snake_case__     (  a	)			->       Dict:





			'''simple docstring'''






			snake_case__          =						"""secretKey"""
			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(a       ,      """login.html"""	)

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

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






'''simple docstring'''


from typing import TYPE_CHECKING

from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available, is_vision_available


_lowerCamelCase					:						Dict					     =							{
    'configuration_donut_swin': ['DONUT_SWIN_PRETRAINED_CONFIG_ARCHIVE_MAP', 'DonutSwinConfig'],
    'processing_donut': ['DonutProcessor'],
}

try:
				if not is_torch_available():
								raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
				pass
else:
				_lowerCamelCase					:						List[str]					     =							[
				    'DONUT_SWIN_PRETRAINED_MODEL_ARCHIVE_LIST',
				    'DonutSwinModel',
				    'DonutSwinPreTrainedModel',
				]

try:
				if not is_vision_available():
								raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
				pass
else:
				_lowerCamelCase					:						Any					     =							['DonutFeatureExtractor']
				_lowerCamelCase					:						Union[str, Any]					     =							['DonutImageProcessor']


if TYPE_CHECKING:
				from .configuration_donut_swin import DONUT_SWIN_PRETRAINED_CONFIG_ARCHIVE_MAP, DonutSwinConfig
				from .processing_donut import DonutProcessor

				try:
								if not is_torch_available():
												raise OptionalDependencyNotAvailable()
				except OptionalDependencyNotAvailable:
								pass
				else:
								from .modeling_donut_swin import (
								    DONUT_SWIN_PRETRAINED_MODEL_ARCHIVE_LIST,
								    DonutSwinModel,
								    DonutSwinPreTrainedModel,
								)

				try:
								if not is_vision_available():
												raise OptionalDependencyNotAvailable()
				except OptionalDependencyNotAvailable:
								pass
				else:
								from .feature_extraction_donut import DonutFeatureExtractor
								from .image_processing_donut import DonutImageProcessor

else:
				import sys

				_lowerCamelCase					:						Optional[int]					     =							_LazyModule(__name__, globals()['__file__'], _import_structure, module_spec=__spec__)

