Skip to content

Migrating from Flask-Mail - Coroutine never awaited #49

Closed Answered by marktennyson
hiven asked this question in Q&A
Discussion options

You must be logged in to vote

Change the view function (I have checked only one scenario).

You need to use asynchronous view function because coroutine function must be awaited.

@auth.route('/register', methods=['GET', 'POST'])
async def register():
    form = RegisterUserForm()
    if form.validate_on_submit():

        user = User.create(
            username=form.data['username'],
            email=form.data['email'],
            password=form.data['password'],
            remote_addr=request.remote_addr,
        )

        s = URLSafeSerializer(current_app.secret_key)
        token = s.dumps(user.id)

        await send_registration_email(user.id, token)

        flash(
            (
                'Sent verifica…

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by marktennyson
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants