1

回溯(最后一次调用):文件“C:/Users/Amabel/PycharmProjects/SystemSecurity/AlienFurniture/main.py”,第 1178 行,在 app.run(debug=True) AttributeError: 'Blueprint' object has no attribute'跑'

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

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

4

1 回答 1

0

好像不对。

蓝图文件,通常称为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)
于 2020-08-14T14:39:42.373 回答