python - AttributeError: 'NotFound' object has no attribute 'encode' -


when user goes on flask app url has more 3 sub paths, "domain.com/var1/var2/var3/var4", throws error below:

traceback (most recent call last): file "/usr/local/lib/python2.7/site-packages/flask/app.py", line 1836, in __call__ return self.wsgi_app(environ, start_response) file "/usr/local/lib/python2.7/site-packages/flask/app.py", line 1820, in wsgi_app response = self.make_response(self.handle_exception(e)) file "/usr/local/lib/python2.7/site-packages/flask/app.py", line 1403, in handle_exception reraise(exc_type, exc_value, tb) file "/usr/local/lib/python2.7/site-packages/flask/app.py", line 1817, in wsgi_app response = self.full_dispatch_request() file "/usr/local/lib/python2.7/site-packages/flask/app.py", line 1478, in    full_dispatch_request response = self.make_response(rv) file "/usr/local/lib/python2.7/site-packages/flask/app.py", line 1574, in make_response rv = self.response_class(rv, headers=headers, status=status) file "/usr/local/lib/python2.7/site-packages/werkzeug/wrappers.py", line 758, in __init__ self.status = status file "/usr/local/lib/python2.7/site-packages/werkzeug/wrappers.py", line 862, in _set_status self._status = to_native(value) file "/usr/local/lib/python2.7/site-packages/werkzeug/_compat.py", line 111, in to_native return x.encode(charset, errors) attributeerror: 'notfound' object has no attribute 'encode' 

it works fine url's have less or equal 3 subpaths "domain.com/var1/var2/var3", have routes url's 1, 2, , 3 subpaths.

how can app go 404 page not found method instead of throwing error?

thank you!

edit.. here's pastebin of route methods i'm using. http://pastebin.com/kjysqk9n

sorry can't provide example of problem, it's weird , don't know how reproduce myself. other flask apps work fine, 1 doesn't. if needs clarification, please let me know... help!

found out why returning error. turns out passing in error object instead of "404" @ end of line:

return render_template("error.html", usa=usa, canada=canada, breadcrumbs=breadcrumbs, error_code=e), 404 

thanks!


Comments

Popular posts from this blog

android - Gradle sync Error:Configuration with name 'default' not found -

java - Andrioid studio start fail: Fatal error initializing 'null' -

html - jQuery UI Sortable - Remove placeholder after item is dropped -