0

I'm having issues making flask work. I'm a noob and still learning about Linux. I'm getting this (very intimidating looking)error after running:

flask run

root@DESKTOP-TV7O885:/mnt/c/Projects/app_1# flask run
 * Serving Flask app "application"
 * Running on http://127.0.0.1:5000/ (Press CTRL+C to quit)
[2018-03-12 14:10:00,550] ERROR in app: Exception on / [GET]
Traceback (most recent call last):
  File "/usr/local/lib/python2.7/dist-packages/flask/app.py", line 1982, in wsgi_app
    response = self.full_dispatch_request()
  File "/usr/local/lib/python2.7/dist-packages/flask/app.py", line 1614, in full_dispatch_request
    rv = self.handle_user_exception(e)
  File "/usr/local/lib/python2.7/dist-packages/flask/app.py", line 1517, in handle_user_exception
    reraise(exc_type, exc_value, tb)
  File "/usr/local/lib/python2.7/dist-packages/flask/app.py", line 1612, in full_dispatch_request
    rv = self.dispatch_request()
  File "/usr/local/lib/python2.7/dist-packages/flask/app.py", line 1598, in dispatch_request
    return self.view_functions[rule.endpoint](**req.view_args)
  File "/mnt/c/Projects/app_1/application.py", line 7, in index
    return render_template("index.html")
  File "/usr/local/lib/python2.7/dist-packages/flask/templating.py", line 133, in render_template
    return _render(ctx.app.jinja_env.get_or_select_template(template_name_or_list),
  File "/usr/local/lib/python2.7/dist-packages/jinja2/environment.py", line 869, in get_or_select_template
    return self.get_template(template_name_or_list, parent, globals)
  File "/usr/local/lib/python2.7/dist-packages/jinja2/environment.py", line 830, in get_template
    return self._load_template(name, self.make_globals(globals))
  File "/usr/local/lib/python2.7/dist-packages/jinja2/environment.py", line 804, in _load_template
    template = self.loader.load(self, name, globals)
  File "/usr/local/lib/python2.7/dist-packages/jinja2/loaders.py", line 113, in load
    source, filename, uptodate = self.get_source(environment, name)
  File "/usr/local/lib/python2.7/dist-packages/flask/templating.py", line 57, in get_source
    return self._get_source_fast(environment, template)
  File "/usr/local/lib/python2.7/dist-packages/flask/templating.py", line 85, in _get_source_fast
    raise TemplateNotFound(template)
TemplateNotFound: index.html
127.0.0.1 - - [12/Mar/2018 14:10:00] "GET / HTTP/1.1" 500 -

and the page then drops

 Internal Server Error
The server encountered an internal error and was unable to complete your request. Either the server is overloaded or there is an error in the application.

I'm also getting a pylint error on VSCODE:

 E0401:Unable to import 'flask'

I understand its probably a relatively simple error because of a bad configuration or installing something wrong. I've been trying to figure this out myself but I have a lot of gaps in my knowledge.

I'm using Bash on Ubuntu on Windows and I think that's why i'm having issues. if anyone could help me or atleast point me in the right direction I would greatly appreciate it

1 Answers1

0

On the call stack in the exception, you must go from bottom to top, until you find a file in your project. This is the starting point. In your case, it is:

File "/mnt/c/Projects/app_1/application.py", line 7, in index
  return render_template("index.html")

You say you have a template named index.html, but (as the exception error), Flask cannot find it. Check that you have such template in the correct place, and you define correctly (when you call Flask constructor) the location of template directory.

Giacomo Catenazzi
  • 8,519
  • 2
  • 24
  • 32