Issue with directory and return render_template

im having an issue with accessing files in my project. Opening an index.html or a .json file in my python code is causing me issues. How do if find the directory of these files in the koyeb server?

UPDATE:
Seems like its also another issue because, when I replaced ‘index.html’ in return_render_template(‘index.html’) with the full html code, it gives me this issue:

NOTE: I am not encountering this problem on the localhost which Koyeb provides in the logs.

File "/app/app.py", line 567, in home
return render_template(index_template)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/app/venv/lib/python3.12/site-packages/flask/templating.py", line 151, in render_template
template = app.jinja_env.get_or_select_template(template_name_or_list)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/app/venv/lib/python3.12/site-packages/jinja2/environment.py", line 1081, in get_or_select_template
return self.get_template(template_name_or_list, parent, globals)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/app/venv/lib/python3.12/site-packages/jinja2/environment.py", line 1010, in get_template
return self._load_template(name, globals)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/app/venv/lib/python3.12/site-packages/jinja2/environment.py", line 969, in _load_template
template = self.loader.load(self, name, self.make_globals(globals))
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/app/venv/lib/python3.12/site-packages/jinja2/loaders.py", line 126, in load
source, filename, uptodate = self.get_source(environment, name)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/app/venv/lib/python3.12/site-packages/flask/templating.py", line 65, in get_source
return self._get_source_fast(environment, template)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/app/venv/lib/python3.12/site-packages/flask/templating.py", line 99, in _get_source_fast
raise TemplateNotFound(template)
jinja2.exceptions.TemplateNotFound: <!DOCTYPE html>

Hey @Daksh_Varyani :wave:

Can you provide a snippet of code we can use to reproduce the issue?

Hi @yann, here you go:

############ app.py##################
from flask import Flask, render_template, request, redirect, url_for, session
app = Flask(name, template_folder=‘templates’)
@app.route(“/”)
def home():
#### testing if return render_template works
return render_template(‘index.html’)

if name == “main”:
app.run(port = 5000)
#### testing if opening a file works
json_file = ‘’
with open(json_file, ‘r’) as file:
data = json.load(file)
#################app.py#################

########## index.html##################

Home

Welcome to the Home Page

################index.html##################

I also created a public github repo with requirements and Dockerfile to make it easier:
(GitHub - dvaryani-bit/test_koyeb)

Hello,

I can see in your Dockerfile that you are copying the app.py file but not the index.html test_koyeb/Dockerfile at main · dvaryani-bit/test_koyeb · GitHub

If you are building using dockerifle, you need to copy the index.html as well.