Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

Python Flask Basics Character Builder Forms

Ajay Kaphola
Ajay Kaphola
1,567 Points

After adding url_for in index.html, web page is not launching.

Python version: 3.4.1 OS Version: Windows 7 Enterprise

After adding url_for in index.html, webpage is not getting launched and received below error after launching: [2016-09-22 13:26:14,007] ERROR in app: Exception on / [GET] Traceback (most recent call last): File "C:\Python34\lib\site-packages\flask-0.11.1-py3.4.egg\flask\app.py", line 1988, in wsgi_app response = self.full_dispatch_request() File "C:\Python34\lib\site-packages\flask-0.11.1-py3.4.egg\flask\app.py", line 1641, in full_dispatch_request rv = self.handle_user_exception(e) File "C:\Python34\lib\site-packages\flask-0.11.1-py3.4.egg\flask\app.py", line 1544, in handle_user_exception reraise(exc_type, exc_value, tb) File "C:\Python34\lib\site-packages\flask-0.11.1-py3.4.egg\flask_compat.py", line 33, in reraise raise value File "C:\Python34\lib\site-packages\flask-0.11.1-py3.4.egg\flask\app.py", line 1639, in full_dispatch_request rv = self.dispatch_request() File "C:\Python34\lib\site-packages\flask-0.11.1-py3.4.egg\flask\app.py", line 1625, in dispatch_request return self.view_functions[rule.endpoint](**req.view_args) File "D:\Ajay\Documents\TreeHouse\Flask\FlaskBasics\Flask-Basics\Flask Basics\Stage 3 Start\app.py", line 9, in index return render_template('index.html') File "C:\Python34\lib\site-packages\flask-0.11.1-py3.4.egg\flask\templating.py", line 133, in render_template return _render(ctx.app.jinja_env.get_or_select_template(template_name_or_list), File "C:\Python34\lib\site-packages\jinja2-2.8-py3.4.egg\jinja2\environment.py", line 851, in get_or_select_template return self.get_template(template_name_or_list, parent, globals) File "C:\Python34\lib\site-packages\jinja2-2.8-py3.4.egg\jinja2\environment.py", line 812, in get_template return self._load_template(name, self.make_globals(globals)) File "C:\Python34\lib\site-packages\jinja2-2.8-py3.4.egg\jinja2\environment.py", line 774, in _load_template cache_key = self.loader.get_source(self, name)[1] File "C:\Python34\lib\site-packages\flask-0.11.1-py3.4.egg\flask\templating.py", line 57, in get_source return self._get_source_fast(environment, template) File "C:\Python34\lib\site-packages\flask-0.11.1-py3.4.egg\flask\templating.py", line 82, in _get_source_fast return loader.get_source(environment, template) File "C:\Python34\lib\site-packages\jinja2-2.8-py3.4.egg\jinja2\loaders.py", line 175, in get_source contents = f.read().decode(self.encoding) UnicodeDecodeError: 'utf-8' codec can't decode byte 0x93 in position 267: invalid start byte 127.0.0.1 - - [22/Sep/2016 13:26:14] "GET / HTTP/1.1" 500 -

Index.html:

{% extends "layout.html" %} {% block content %} <!--Enter Name --> <div class="enter-name"> <div class="grid-100"> <img src="/static/img/bear_avatar.svg" class="bear-avatar" /> </div> <div class="grid-100"> <form action="{{url_for(“save”)}}" method="POST"> <label>Name your bear</label> <input type="text" name="name" value="" autofocus> <input type="submit" value="Let's build it!"> </form> </div> </div> {% endblock %}

Please help me with this.

Robust Tran
Robust Tran
2,802 Points

You should include your code snippet for please the eyes. This is a pain in the eyes to read the error.

Juliana Demarque
Juliana Demarque
14,502 Points

I know it's been months already but if this will help anyone, I think the error was at the line

<form action="{{url_for(“save”)}}" method="POST">

The Jinja block has double quotes around the url_for() parameter while the html attribute also has double quotes, so the second time the quotes appear it's closing the attribute earlier, thus resulting in error.