Welcome toVigges Developer Community-Open, Learning,Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
231 views
in Technique[技术] by (71.8m points)

python - Firestore get() fetches no data in Flask

I'm unable to get data from the firebase cloud firestore on my production server. I have the following code:

@app.route('/forgot-password', methods=['GET','POST'])
def forgotpassword():

    if 'email' in session:
        return redirect(url_for('profile'))

    form = ForgotPasswordForm() 
    if form.validate_on_submit():

        try:
            user_ref = db.collection(u'users').document(form.email.data)
            user = user_ref.get()
        except Exception as e:
            print(e)
        if user.exists:
            try:
                auth.send_password_reset_email(form.email.data)
                print(form.email.data)

                flash('A link to reset your password has been sent to your mail.', 'success')
            except Exception as e:
                print(e)
                flash('There was an error while sending the email.', 'danger')      

        else:           
            print("not registerd")
            flash('This email is not registered.', 'danger')

    print(form.errors)

    return render_template('forgotPasswordPage.html', form=form)

I am not getting any output for the exception since none seems to be thrown. The same code works on my localhost but not on the production server.

db.collection(u'users').document(form.email.data) succesfully returns a firestore document object but the get() function is the one causing the problem. What could be the problem?


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)
等待大神答复

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to Vigges Developer Community for programmer and developer-Open, Learning and Share
...