Flask confusion with app

前端 未结 3 1139
眼角桃花
眼角桃花 2020-12-29 19:26

I am starting a flask project, and in my code I have

from flask import Flask, render_template, abort
app = Flask(__name__)

Now

3条回答
  •  鱼传尺愫
    2020-12-29 19:57

    The author made his code needlessly confusing by choosing a package name that is the same as Flask's usual application object instance name. This is the one you'll be most interested in:

    app = Flask(__name__)
    

    Here is the documentation on the Flask application object:

    http://flask.pocoo.org/docs/api/#application-object

    To avoid confusion, I recommend using the official Flask documentation instead of that guide.

提交回复
热议问题