So I'm following along with the tutorial on Flask from LinkedIn: "Full Stack Web Development with Flask ". And I ran into this issue on the topic of routing using templates. I don't know what is casuing the issue since I'm very new to Flask and I haven't seen anything about it on the documentation. What I think it is is that I must've coded something that Flask cannot run, syntax-wise,since it's Flask's own files that are producing the issues from the compiler. I am sure that the issue is coming from the routing because the error happens after I run "flask run" on the command line and then reload the page.
Error messages:
File "c:\users\user\desktop\flask\enrollment\venv\lib\site-packages\flask\app.py", line 2446, in wsgi_app response = self.full_dispatch_request() File "c:\users\user\desktop\flask\enrollment\venv\lib\site-packages\flask\app.py", line 1951, in full_dispatch_request rv = self.handle_user_exception(e) File "c:\users\user\desktop\flask\enrollment\venv\lib\site-packages\flask\app.py", line 1820, in handle_user_exception reraise(exc_type, exc_value, tb) File "c:\users\user\desktop\flask\enrollment\venv\lib\site-packages\flask\_compat.py", line 39, in reraise raise value File "c:\users\user\desktop\flask\enrollment\venv\lib\site-packages\flask\app.py", line 1949, in full_dispatch_request rv = self.dispatch_request() File "c:\users\user\desktop\flask\enrollment\venv\lib\site-packages\flask\app.py", line 1935, in dispatch_request return self.view_functions[rule.endpoint](**req.view_args) File "C:\Users\user\Desktop\flask\enrollment\application\routes.py", line 7, in index return render_template('index.html') File "c:\users\user\desktop\flask\enrollment\venv\lib\site-packages\flask\templating.py", line 137, in render_template return _render( File "c:\users\user\desktop\flask\enrollment\venv\lib\site-packages\flask\templating.py", line 120, in _render rv = template.render(context) File "c:\users\user\desktop\flask\enrollment\venv\lib\site-packages\jinja2\asyncsupport.py", line 76, in render return original_render(self, *args, **kwargs) File "c:\users\user\desktop\flask\enrollment\venv\lib\site-packages\jinja2\environment.py", line 1008, in render return self.environment.handle_exception(exc_info, True) File "c:\users\user\desktop\flask\enrollment\venv\lib\site-packages\jinja2\environment.py", line 780, in handle_exception reraise(exc_type, exc_value, tb) File "c:\users\user\desktop\flask\enrollment\venv\lib\site-packages\jinja2\_compat.py", line 37, in reraise raise value.with_traceback(tb) File "C:\Users\user\Desktop\flask\enrollment\application\templates\index.html", line 16, in {% include "includes/nav.html" %} File "c:\users\user\desktop\flask\enrollment\venv\lib\site-packages\jinja2\environment.py", line 1005, in render return concat(self.root_render_func(self.new_context(vars))) File "C:\Users\user\Desktop\flask\enrollment\application\templates\index.html", line 14, in root File "C:\Users\user\Desktop\flask\enrollment\application\templates\includes\nav.html", line 13, in root File "c:\users\user\desktop\flask\enrollment\venv\lib\site-packages\jinja2\runtime.py", line 262, in call return __obj(*args, **kwargs) File "c:\users\user\desktop\flask\enrollment\venv\lib\site-packages\flask\helpers.py", line 370, in url_for return appctx.app.handle_url_build_error(error, endpoint, values) File "c:\users\user\desktop\flask\enrollment\venv\lib\site-packages\flask\app.py", line 2215, in handle_url_build_error reraise(exc_type, exc_value, tb) File "c:\users\user\desktop\flask\enrollment\venv\lib\site-packages\flask\_compat.py", line 39, in reraise raise value File "c:\users\user\desktop\flask\enrollment\venv\lib\site-packages\flask\helpers.py", line 357, in url_for rv = url_adapter.build( File "c:\users\user\desktop\flask\enrollment\venv\lib\site-packages\werkzeug\routing.py", line 2020, in build raise BuildError(endpoint, values, method, self) werkzeug.routing.BuildError: Could not build url for endpoint 'courses'. Did you mean 'index' instead? 127.0.0.1 - - [10/Nov/2019 09:42:23] "GET /index HTTP/1.1" 500 -
routes.py
from application import app
from flask import render_template
@app.route('/index')
def index():
return render_template('index.html')
index.html:
<!DOCTYPE html>
<html>
<head>
<title>UTA - Home Page</title>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css"
integrity="sha384-Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm" crossorigin="anonymous">
<link rel="stylesheet" href="static/css/main.css"/>
</head>
<body>
<div class="container-fluid text-center top-container">
<img src="static/images/uta-logo-200.png">
</div>
<div class="container">
{% include "includes/nav.html" %}
<div class="row">
<div class="col-md-12 text-center">
<h1>Welcome to Universal Tech Academy.</h1>
{% if login %}
<h3>Let's get started.</h3>
{% else %}
<p>Already registered? <a href="{{url_for('login') }}">Login</a></p>
{% endif %}
</div>
</div>
</div>
{% include "includes/footer.html" %}
</body>
</html>