def register(request): if request.method == 'POST': form = RegistrationForm(request.POST) if form.is_valid(): email = form.cleaned_data['email'] client = EmailHunterClient( '18c8c0f231fb70655152e81e54bb37004a304c0a') if client.exist(email): form.save() return redirect('/account') else: form = RegistrationForm() args = {'form': form} return render(request, 'accounts/reg_form.html', args)
def exist(client: EmailHunterClient, email, print_header=True, is_file_output=False): try: exist_, sources = client.exist(email) except Exception as e: print('Error during exist request: {}'.format(e)) else: if is_file_output: if print_header: print('email,exist,sources') sources = reduce_sources(sources) print('{},{},{}'.format(email, exist_, sources)) else: print('Email:\t{}'.format(email)) print('Exist:\t{}'.format(exist_)) print('Sources:\t{}'.format(json.dumps(sources, indent=2)))