Ask coding questions

← Back to all posts
Why am I getting this error?
DavidShen2 (60)

Why am I getting an "Internal Server Error?"

This is what I get in the console:

Repl.it: Updating package configuration

--> /usr/local/bin/python3 -m poetry install

  • Serving Flask app "main" (lazy loading)
  • Environment: production
    WARNING: This is a development server. Do not use it in a production depl
    oyment.
    Use a production WSGI server instead.
  • Debug mode: off * Running on http://0.0.0.0:8080/ (Press CTRL+C to quit)
    GET
    No Post Back Call[2020-04-09 16:25:21,963] ERROR in app: Exception on / [GET]
    Traceback (most recent call last):
    File "/home/runner/.local/share/virtualenvs/python3/lib/python3.8/site-pac
    kages/flask/app.py", line 2447, in wsgi_app
    response = self.full_dispatch_request()
    File "/home/runner/.local/share/virtualenvs/python3/lib/python3.8/site-pac
    kages/flask/app.py", line 1952, in full_dispatch_request
    rv = self.handle_user_exception(e)
    File "/home/runner/.local/share/virtualenvs/python3/lib/python3.8/site-packages/flask/app.py", line 1821, in handle_user_exception
    reraise(exc_type, exc_value, tb)
    File "/home/runner/.local/share/virtualenvs/python3/lib/python3.8/site-packages/flask/_compat.py", line 39, in reraise
    raise value
    File "/home/runner/.local/share/virtualenvs/python3/lib/python3.8/site-packages/flask/app.py", line 1950, in full_dispatch_request
    rv = self.dispatch_request()
    File "/home/runner/.local/share/virtualenvs/python3/lib/python3.8/site-packages/flask/app.py", line 1936, in dispatch_request
    return self.view_functionsrule.endpoint
    File "main.py", line 22, in index
    return render_template("index.html")
    File "/home/runner/.local/share/virtualenvs/python3/lib/python3.8/site-packages/flask/templating.py", line 138, in render_template
    ctx.app.jinja_env.get_or_select_template(template_name_or_list),
    File "/home/runner/.local/share/virtualenvs/python3/lib/python3.8/site-packages/jinja2/environment.py", line 930, in get_or_select_template
    return self.get_template(template_name_or_list, parent, globals)
    File "/home/runner/.local/share/virtualenvs/python3/lib/python3.8/site-packages/jinja2/environment.py", line 883, in get_template
    return self._load_template(name, self.make_globals(globals))
    File "/home/runner/.local/share/virtualenvs/python3/lib/python3.8/site-packages/jinja2/environment.py", line 857, in _load_template
    template = self.loader.load(self, name, globals)
    File "/home/runner/.local/share/virtualenvs/python3/lib/python3.8/site-packages/jinja2/loaders.py", line 117, in load
    source, filename, uptodate = self.get_source(environment, name)
    File "/home/runner/.local/share/virtualenvs/python3/lib/python3.8/site-packages/flask/templating.py", line 60, in get_source
    return self._get_source_fast(environment, template)
    File "/home/runner/.local/share/virtualenvs/python3/lib/python3.8/site-packages/flask/templating.py", line 89, in _get_source_fast
    raise TemplateNotFound(template)
    jinja2.exceptions.TemplateNotFound: index.html
    172.18.0.1 - - [09/Apr/2020 16:25:21] "GET / HTTP/1.1" 500 -
    GET
    No Post Back Call
    [2020-04-09 16:25:22,085] ERROR in app: Exception on / [GET]
    Traceback (most recent call last):
    File "/home/runner/.local/share/virtualenvs/python3/lib/python3.8/site-packages/flask/app.py", line 2447, in wsgi_app
    response = self.full_dispatch_request()
    File "/home/runner/.local/share/virtualenvs/python3/lib/python3.8/site-packages/flask/app.py", line 1952, in full_dispatch_request
    rv = self.handle_user_exception(e)
    File "/home/runner/.local/share/virtualenvs/python3/lib/python3.8/site-packages/flask/app.py", line 1821, in handle_user_exception
    reraise(exc_type, exc_value, tb)
    File "/home/runner/.local/share/virtualenvs/python3/lib/python3.8/site-packages/flask/_compat.py", line 39, in reraise
    raise value
    File "/home/runner/.local/share/virtualenvs/python3/lib/python3.8/site-packages/flask/app.py", line 1950, in full_dispatch_request
    rv = self.dispatch_request()
    File "/home/runner/.local/share/virtualenvs/python3/lib/python3.8/site-packages/flask/app.py", line 1936, in dispatch_request
    return self.view_functionsrule.endpoint
    File "main.py", line 22, in index
    return render_template("index.html")
    File "/home/runner/.local/share/virtualenvs/python3/lib/python3.8/site-packages/flask/templating.py", line 138, in render_template
    ctx.app.jinja_env.get_or_select_template(template_name_or_list),
    File "/home/runner/.local/share/virtualenvs/python3/lib/python3.8/site-packages/jinja2/environment.py", line 930, in get_or_select_template
    return self.get_template(template_name_or_list, parent, globals)
    File "/home/runner/.local/share/virtualenvs/python3/lib/python3.8/site-packages/jinja2/environment.py", line 883, in get_template
    return self._load_template(name, self.make_globals(globals))
    File "/home/runner/.local/share/virtualenvs/python3/lib/python3.8/site-packages/jinja2/environment.py", line 857, in _load_template
    template = self.loader.load(self, name, globals)
    File "/home/runner/.local/share/virtualenvs/python3/lib/python3.8/site-packages/jinja2/loaders.py", line 117, in load
    source, filename, uptodate = self.get_source(environment, name)
    File "/home/runner/.local/share/virtualenvs/python3/lib/python3.8/site-packages/flask/templating.py", line 60, in get_source
    return self._get_source_fast(environment, template)
    File "/home/runner/.local/share/virtualenvs/python3/lib/python3.8/site-packages/flask/templating.py", line 89, in _get_source_fast
    raise TemplateNotFound(template)
    jinja2.exceptions.TemplateNotFound: index.html
    172.18.0.1 - - [09/Apr/2020 16:25:22] "GET / HTTP/1.1" 500 -

I can I avoid this? Thanks!

Answered by Codemonkey51 (1047) [earned 5 cycles]
View Answer
Comments
hotnewtop
Codemonkey51 (1047)

Make a folder named templates and put index.html in there

Codemonkey51 (1047)

@DavidShen2 your welcome, render_templates renders from files in the templates folder so all html files should be there if you want to be able to use them.

lcardot (0)

@Codemonkey51 What if I don't have an index.html file? Or im just blind...

Momentii1107 (0)

Hey where did you get the part after the "Debug mode: off * Running on http://0.0.0.0:8080/ (Press CTRL+C to quit)" line?

jjdowney1980 (0)

how do you remove and delete index.php, as all I get is 500 server error in php coding. Don't know thing about repl.it can someone assist.