question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Missing template in flask_embed.py and tornado_embed.py

See original GitHub issue

The flask_embed.py and tornado_embed.py examples are not self-contained in that they need an embed.html template. Running flask_embed.py as it appears in the repository leads to the following error:

$ python flask_embed.py 
Opening Flask app with embedded Bokeh application on http://localhost:8080/
[2017-01-16 21:29:37,150] ERROR in app: Exception on / [GET]
Traceback (most recent call last):
  File "/home/juanlu/.miniconda3/envs/py35/lib/python3.5/site-packages/flask/app.py", line 1982, in wsgi_app
    response = self.full_dispatch_request()
  File "/home/juanlu/.miniconda3/envs/py35/lib/python3.5/site-packages/flask/app.py", line 1614, in full_dispatch_request
    rv = self.handle_user_exception(e)
  File "/home/juanlu/.miniconda3/envs/py35/lib/python3.5/site-packages/flask/app.py", line 1517, in handle_user_exception
    reraise(exc_type, exc_value, tb)
  File "/home/juanlu/.miniconda3/envs/py35/lib/python3.5/site-packages/flask/_compat.py", line 33, in reraise
    raise value
  File "/home/juanlu/.miniconda3/envs/py35/lib/python3.5/site-packages/flask/app.py", line 1612, in full_dispatch_request
    rv = self.dispatch_request()
  File "/home/juanlu/.miniconda3/envs/py35/lib/python3.5/site-packages/flask/app.py", line 1598, in dispatch_request
    return self.view_functions[rule.endpoint](**req.view_args)
  File "flask_embed.py", line 43, in bkapp_page
    return render_template("embed.html", script=script)
  File "/home/juanlu/.miniconda3/envs/py35/lib/python3.5/site-packages/flask/templating.py", line 133, in render_template
    return _render(ctx.app.jinja_env.get_or_select_template(template_name_or_list),
  File "/home/juanlu/.miniconda3/envs/py35/lib/python3.5/site-packages/jinja2/environment.py", line 851, in get_or_select_template
    return self.get_template(template_name_or_list, parent, globals)
  File "/home/juanlu/.miniconda3/envs/py35/lib/python3.5/site-packages/jinja2/environment.py", line 812, in get_template
    return self._load_template(name, self.make_globals(globals))
  File "/home/juanlu/.miniconda3/envs/py35/lib/python3.5/site-packages/jinja2/environment.py", line 774, in _load_template
    cache_key = self.loader.get_source(self, name)[1]
  File "/home/juanlu/.miniconda3/envs/py35/lib/python3.5/site-packages/flask/templating.py", line 57, in get_source
    return self._get_source_fast(environment, template)
  File "/home/juanlu/.miniconda3/envs/py35/lib/python3.5/site-packages/flask/templating.py", line 85, in _get_source_fast
    raise TemplateNotFound(template)
jinja2.exceptions.TemplateNotFound: embed.html

And putting examples/embed/simple/templates/embed.html under templates/ yields this:

$ python flask_embed.py   
Opening Flask app with embedded Bokeh application on http://localhost:8080/
[2017-01-16 21:30:38,094] ERROR in app: Exception on / [GET]
Traceback (most recent call last):
  File "/home/juanlu/.miniconda3/envs/py35/lib/python3.5/site-packages/flask/app.py", line 1982, in wsgi_app
    response = self.full_dispatch_request()
  File "/home/juanlu/.miniconda3/envs/py35/lib/python3.5/site-packages/flask/app.py", line 1614, in full_dispatch_request
    rv = self.handle_user_exception(e)
  File "/home/juanlu/.miniconda3/envs/py35/lib/python3.5/site-packages/flask/app.py", line 1517, in handle_user_exception
    reraise(exc_type, exc_value, tb)
  File "/home/juanlu/.miniconda3/envs/py35/lib/python3.5/site-packages/flask/_compat.py", line 33, in reraise
    raise value
  File "/home/juanlu/.miniconda3/envs/py35/lib/python3.5/site-packages/flask/app.py", line 1612, in full_dispatch_request
    rv = self.dispatch_request()
  File "/home/juanlu/.miniconda3/envs/py35/lib/python3.5/site-packages/flask/app.py", line 1598, in dispatch_request
    return self.view_functions[rule.endpoint](**req.view_args)
  File "flask_embed.py", line 43, in bkapp_page
    return render_template("embed.html", script=script)
  File "/home/juanlu/.miniconda3/envs/py35/lib/python3.5/site-packages/flask/templating.py", line 134, in render_template
    context, ctx.app)
  File "/home/juanlu/.miniconda3/envs/py35/lib/python3.5/site-packages/flask/templating.py", line 116, in _render
    rv = template.render(context)
  File "/home/juanlu/.miniconda3/envs/py35/lib/python3.5/site-packages/jinja2/environment.py", line 989, in render
    return self.environment.handle_exception(exc_info, True)
  File "/home/juanlu/.miniconda3/envs/py35/lib/python3.5/site-packages/jinja2/environment.py", line 754, in handle_exception
    reraise(exc_type, exc_value, tb)
  File "/home/juanlu/.miniconda3/envs/py35/lib/python3.5/site-packages/jinja2/_compat.py", line 37, in reraise
    raise value.with_traceback(tb)
  File "/tmp/templates/embed.html", line 9, in top-level template code
    {{ js_resources|indent(4)|safe }}
  File "/home/juanlu/.miniconda3/envs/py35/lib/python3.5/site-packages/jinja2/filters.py", line 453, in do_indent
    rv = (u'\n' + indention).join(s.splitlines())
jinja2.exceptions.UndefinedError: 'js_resources' is undefined

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:8 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
bryevdvcommented, Jan 28, 2017

I went ahead and added this, thanks for pointing it out @Juanlu001

1reaction
bryevdvcommented, Jan 18, 2017

Great! I just wanted to make sure you had the opportunity to, if you wanted to, before anyone else worked on it. 😃

Read more comments on GitHub >

github_iconTop Results From Across the Web

python 3.x - Flask Application Factory missing templates folder
I converted some of my apps to application factory. After converting the apps the templates folder can't be found. /newsite wsgi.py ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found