

import requests

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




def        _lowercase  (					a_					:       Optional[int]					)					->						Optional[int]:




					'''simple docstring'''







					__magic_name__				=     """secretKey"""
					__magic_name__				=     """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
					__magic_name__				=     request.POST.get('username'					)
					__magic_name__				=     request.POST.get('password'					)
					__magic_name__				=     request.POST.get('g-recaptcha-response'					)

					# post recaptcha response to Google's recaptcha api
					__magic_name__				=     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
										__magic_name__				=     authenticate(a_       ,username=a_       ,password=a_					)
										if user_in_database:
															login(a_       ,a_					)
															return redirect('/your-webpage'					)
					return render(a_       ,'login.html'					)












'''simple docstring'''







import unittest
from pathlib import Path

from transformers import is_vision_available, load_tool
from transformers.testing_utils import get_tests_dir

from .test_tools_common import ToolTesterMixin


if is_vision_available():
			from PIL import Image

class _lowercase      (							unittest.TestCase							, _lowercase						):




							def 						lowerCamelCase_							(				self:							Tuple	):
														lowerCamelCase__   :      Optional[Any]			    =			load_tool("""image-captioning"""	)
														self.tool.setup()
														lowerCamelCase__   :      Optional[Any]			    =			load_tool("""image-captioning"""     ,				remote=UpperCamelCase__	)




							def 						lowerCamelCase_							(				self:							int	):
														lowerCamelCase__   :      List[Any]			    =			Image.open(Path(get_tests_dir("""fixtures/tests_samples/COCO"""	)	) / """000000039769.png"""	)
														lowerCamelCase__   :      Optional[Any]			    =			self.tool(UpperCamelCase__	)
														self.assertEqual(UpperCamelCase__     ,				"""two cats sleeping on a couch"""	)




							def 						lowerCamelCase_							(				self:							Union[str, Any]	):
														lowerCamelCase__   :      Tuple			    =			Image.open(Path(get_tests_dir("""fixtures/tests_samples/COCO"""	)	) / """000000039769.png"""	)
														lowerCamelCase__   :      Dict			    =			self.remote_tool(UpperCamelCase__	)
														self.assertEqual(UpperCamelCase__     ,				"""two cats sleeping on a couch"""	)




							def 						lowerCamelCase_							(				self:							str	):
														lowerCamelCase__   :      Optional[int]			    =			Image.open(Path(get_tests_dir("""fixtures/tests_samples/COCO"""	)	) / """000000039769.png"""	)
														lowerCamelCase__   :      str			    =			self.tool(image=UpperCamelCase__	)
														self.assertEqual(UpperCamelCase__     ,				"""two cats sleeping on a couch"""	)




							def 						lowerCamelCase_							(				self:							Union[str, Any]	):
														lowerCamelCase__   :      Optional[int]			    =			Image.open(Path(get_tests_dir("""fixtures/tests_samples/COCO"""	)	) / """000000039769.png"""	)
														lowerCamelCase__   :      Optional[int]			    =			self.remote_tool(image=UpperCamelCase__	)
														self.assertEqual(UpperCamelCase__     ,				"""two cats sleeping on a couch"""	)

