<commit_before>import logging
from os import getenv

from flask import redirect, render_template, url_for
from structlog import wrap_logger

from frontstage import app
from frontstage.common.api_call import api_call
from frontstage.common.cryptographer import Cryptographer
from frontstage.exceptions.exceptions import ApiError
from frontstage.views.register import register_bp


logger = wrap_logger(logging.getLogger(__name__))
cryptographer = Cryptographer()


@register_bp.route('/activate-account/<token>', methods=['GET'])
def register_activate_account(token):
    logger.info('Attempting to verify email')
    response = api_call('PUT', app.config['VERIFY_EMAIL'], parameters={'token': token})

    # Handle api errors
    if response.status_code == 409:
        logger.info('Expired email verification token', token=token)
        return render_template('register/register.link-expired.html', _theme='default')
    elif response.status_code == 404:
        logger.warning('Unrecognised email verification token', token=token)
        return redirect(url_for('error_bp.not_found_error_page'))
    elif response.status_code != 200:
        logger.info('Failed to verify email')
        raise ApiError(response)<commit_msg>Remove unused cryptographer import and creation (#296)<commit_after>import logging
from os import getenv

from flask import redirect, render_template, url_for
from structlog import wrap_logger

from frontstage import app
from frontstage.common.api_call import api_call
from frontstage.exceptions.exceptions import ApiError
from frontstage.views.register import register_bp


logger = wrap_logger(logging.getLogger(__name__))


@register_bp.route('/activate-account/<token>', methods=['GET'])
def register_activate_account(token):
    logger.info('Attempting to verify email')
    response = api_call('PUT', app.config['VERIFY_EMAIL'], parameters={'token': token})

    # Handle api errors
    if response.status_code == 409:
        logger.info('Expired email verification token', token=token)
        return render_template('register/register.link-expired.html', _theme='default')
    elif response.status_code == 404:
        logger.warning('Unrecognised email verification token', token=token)
        return redirect(url_for('error_bp.not_found_error_page'))
    elif response.status_code != 200:
        logger.info('Failed to verify email')
        raise ApiError(response)
{'fraction_non_alphanumeric': 0.09721645201495638, 'fraction_numerical': 0.008724553385957623, 'mean_word_length': 5.142857142857143, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3511493', 'n_tokens_mistral': 672, 'n_tokens_neox': 642, 'n_words': 171}