I'm trying to run my flask application - which was working fine last night. However, this morning, attempting to run the same code (on a different computer, however), I'm getting the error:
jinja2.exceptions.UndefinedError: 'flask.sessions.SecureCookieSession object' has no attribute 'favicon.ico'
Full traceback:
Traceback (most recent call last):
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/flask/app.py", line 1997, in __call__
return self.wsgi_app(environ, start_response)
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/flask/app.py", line 1985, in wsgi_app
response = self.handle_exception(e)
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/flask/app.py", line 1540, in handle_exception
reraise(exc_type, exc_value, tb)
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/flask/_compat.py", line 33, in reraise
raise value
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/flask/app.py", line 1982, in wsgi_app
response = self.full_dispatch_request()
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/flask/app.py", line 1614, in full_dispatch_request
rv = self.handle_user_exception(e)
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/flask/app.py", line 1517, in handle_user_exception
reraise(exc_type, exc_value, tb)
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/flask/_compat.py", line 33, in reraise
raise value
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/flask/app.py", line 1612, in full_dispatch_request
rv = self.dispatch_request()
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/flask/app.py", line 1598, in dispatch_request
return self.view_functions[rule.endpoint](**req.view_args)
File "/Users//Desktop/survey-system/scripts/routes.py", line 88, in course_survey
return render_template("survey.html", course=course)
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/flask/templating.py", line 134, in render_template
context, ctx.app)
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/flask/templating.py", line 116, in _render
rv = template.render(context)
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/jinja2/asyncsupport.py", line 76, in render
return original_render(self, *args, **kwargs)
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/jinja2/environment.py", line 1008, in render
return self.environment.handle_exception(exc_info, True)
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/jinja2/environment.py", line 780, in handle_exception
reraise(exc_type, exc_value, tb)
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/jinja2/_compat.py", line 37, in reraise
raise value.with_traceback(tb)
File "/Users//Desktop/survey-system/templates/survey.html", line 10, in top-level template code
{% for q, a in zip(session[course]["questions"], session[course]["answers"]) %}
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/jinja2/environment.py", line 411, in getitem
return obj[argument]
jinja2.exceptions.UndefinedError: 'flask.sessions.SecureCookieSession object' has no attribute 'favicon.ico'
survey.html
<body>
<h1 align="left"> This is the survey for {{course}}</h1>
<form>
{% for q, a in zip(session[course]["questions"], session[course]["answers"]) %}
... do stuff ...
routes.py (relevant code)
@app.template_global(name='zip')
def _zip(*args, **kwargs): # So that jinja may use the zip function
return zip(*args, **kwargs)
@app.route('/<string:course>', methods=['GET', 'POST'])
def course_survey(course):
return render_template("survey.html", course=course)
@app.route('/questionbank', methods=['GET', 'POST'])
def q_bank():
if request.method == "POST":
...
...
elif "final-survey" in request.form:
...
new_survey = Survey(x, y, z) # Where Survey is a custom class created
return redirect(url_for("course_survey", course=new_survey))
Nowhere in my code am I attempting to create my own favicon, either through flask or through the HTML directly.
The script also never breaks - the webpages load fine and function normally, but I'm getting this traceback on every route.