Linked Questions

Popular Questions

Why is this simple Flask script taking so long to run?

Asked by At

It's just a script that sends a mail once a form is submitted:

@application.route('/contact', methods=['GET', 'POST'])
def send():
    if request.method == 'POST':
        first_name = request.form['first_name']
        last_name = request.form['last_name']
        email = request.form['email']
        msg = Message('Hey!', sender='[email protected]', recipients=['[email protected]'])
        msg.body = email + " " + first_name + " " + last_name + " "
        msg2 = Message('Hello', sender='[email protected]', recipients=[email])
        msg2.body = "Hi " + first_name + ". Thanks for requesting access to our beta. We'll contact you soon to schedule a call."

        return render_template('contact.html')

    return render_template ('index.html')

Both emails get delivered, but it takes too long for the script to be processed, which is resulting in fewer signups. What's wrong?

Just in case, I'm hosting this Flask application on an Elastic Beanstalk instance.

Related Questions