def METHOD_NAME():
    mc = MailChimp(mc_api=app.config["MAILCHIMP_KEY"])
    try:
        email = request.form.get("email")
        try:
            data = mc.lists.members.create_or_update(
                list_id=app.config["MAILCHIMP_LIST"],
                subscriber_hash=get_subscriber_hash(email),
                data={
                    "email_address": email,
                    "status": "subscribed",
                    "status_if_new": "pending",
                },
            )
            status = data.get("status")
            if status == "pending":
                flash(
                    "Thanks for subscribing! You will receive a confirmation email shortly."
                )
            elif status == "subscribed":
                flash("You were already subscribed! Thanks for checking back.")
            else:
                raise ValueError("Unexpected status %s" % status)
        except ValueError as e:
            # ugh, this library is awful
            app.logger.info(
                "ValueError from mailchimp3 %s, assuming bad email: %r", e, email
            )
            flash("Your email address was not accepted - please check and try again.")
        except MailChimpError as e:
            # Either the JSON, or a dictionary containing the response
            (data,) = e.args
            if data.get("status") != 400:
                raise
            title = data.get("title")
            if title == "Member In Compliance State":
                app.logger.info("Member in compliance state: %r", email)
                flash(
                    """You've already been unsubscribed from our list, so we can't add you again.
                         Please contact %s to update your settings."""
                    % app.config["TICKETS_EMAIL"][1]
                )
            elif title == "Invalid Resource":
                app.logger.warn(
                    "Invalid Resource from MailChimp, likely bad email or rate limited: %r",
                    email,
                )
                flash(
                    """Your email address was not accepted - please check and try again.
                       If you've signed up to other lists recently, please wait 48 hours."""
                )
            else:
                app.logger.warn("MailChimp returned %s: %s", title, data.get("detail"))
                flash("Sorry, an error occurred: %s." % (title or "unknown"))
    except Exception as e:
        app.logger.exception("Error subscribing: %r", e)
        flash("Sorry, an error occurred.")
    return redirect(url_for(".main"))