Issue
I'm a new in the Flask framework. Already written a few apps, but I faced with a problem recently. In case I add a second @app.route decorator app.run stop working(app.run(debug=True) AttributeError: 'function' object has no attribute 'run'), indentations look good, like in my other working apps. Already tried to re-create virtualenv. Could you please take a look?
` from flask import Flask, render_template, redirect
app = Flask(__name__)
@app.route('/')
def index():
return render_template('index.html')
@app.route('/imgapp')
def app():
return render_template('img_app.html')
if __name__ == '__main__':
app.run(debug=True)`
Solution
You cannot call your function "app", as you have set at the top
app = Flask(__name__)
Flask gets confused by this when app is then reassigned as a function. Just change the function name to anything else.
Answered By - thetaco
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.