2

I created a .pyz application, here is the structure:

myapp
┣ templates
┃ ┗ index.j2
┗ main.py

In main program i have this:

j2_env = jinja2.Environment(loader=jinja2.FileSystemLoader('templates'), trim_blocks=True)
st = j2_env.get_template('index.j2').render()

When trying to execute the program I receive error: jinja2.exceptions.TemplateNotFound: index.j2

How to get access to template directory inside the zipapp? It works perfectly using .py file, outside of package.

Pawara Siriwardhane
  • 1,873
  • 10
  • 26
  • 38
Gomo55
  • 21
  • 2
  • Maybe duplicate of this: https://stackoverflow.com/questions/60357727/how-to-make-flask-jinja2-load-bundled-templates-in-an-executable-zip-archive – sinoroc Jan 10 '23 at 14:58

0 Answers0