【问题标题】:I am trying to integrate Google Sign into my python, flask web application and i got the following error我正在尝试将 Google Sign 集成到我的 python、flask Web 应用程序中,但出现以下错误
【发布时间】:2020-08-14 07:06:13
【问题描述】:

Traceback(最近一次调用最后一次): 文件“C:/Users/Amabel/PycharmProjects/SystemSecurity/AlienFurniture/main.py”,第 1178 行,在 应用程序运行(调试=真) AttributeError:“蓝图”对象没有属性“运行”

app = flask.Blueprint('google_auth', __name__)

我的方法是否正确?如何将 Google 登录选项集成到带有 mysql 数据库的 python 烧瓶 Web 应用程序中?

【问题讨论】:

    标签: python flask google-auth-library


    【解决方案1】:

    好像不对。

    蓝图文件,通常称为views.py

    from flask import blueprint, render_template
    
    google_auth = Blueprint('google_auth', __name__)
    
    @google_auth.route('/auth', methods=['GET', 'POST'])
    def auth():
        #do staff
        return render_template('auth.html')
    

    应用程序文件 app.py

    form flask import Flask
    from flask_sqlalchemy import SQLAlchemy
    
    app = Flask(__name__)
    app.config['SQLALCHEMY_DATABASE_URI'] = 'sqlite:////tmp/test.db'
    db = SQLAlchemy(app)
    
    #do stuff
    
    
    #import the blueprint
    #Important note, import the blueprint after the Database functions
    
    from myapp.auth.views import google_auth
    app.register_blueprint(google_auth)
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2020-05-01
      • 1970-01-01
      • 2017-07-18
      • 2016-02-23
      • 1970-01-01
      • 2020-09-03
      • 2020-07-02
      • 1970-01-01
      相关资源
      最近更新 更多