title: werkzeug.routing.BuildError: Could not build url for endpoint
body: <p>I have created a web API to render a webpage with navigation. Below is my code</p>
  
  <pre><code>from flask import Flask, render_template, request
  
  app = Flask(__name__)
  
  @app.route('/testsite/')
  def home():
      return render_template('home.html')
  if __name__ == '__main__':
      app.run(debug=True)
  
  @app.route('/about/')
  def about():
  
          return render_template('about.html')
  
  if __name__ == '__main__':
      app.run(debug=True)
  </code></pre>
  
  <p>Below is the HTML code for both html templates</p>
  
  <p><strong>home.html</strong></p>
  
  <pre><code>&lt;!DOCTYPE html&gt;
  &lt;html&gt;
  &lt;body&gt;
  {% extends "layout.html" %}
  {% block content %}
  &lt;div class="home"&gt;
  &lt;h1&gt;My Personal Website&lt;/h1&gt;
  &lt;p&gt;Hi, this is my personal website.&lt;/p&gt;
  &lt;/div&gt;
  {% endblock %}
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p><strong>about.html</strong></p>
  
  <pre><code>&lt;!DOCTYPE html&gt;
  &lt;html&gt;
  &lt;body&gt;
  {% extends "layout.html" %}
  {% block content %}
  &lt;div class="about"&gt;
  &lt;h1&gt;About me&lt;/h1&gt;
  &lt;img src="{{ user_image }}" alt="User Image"&gt;
  &lt;p&gt;Update about yourself here&lt;/p&gt;
  &lt;/div&gt;
  {% endblock %}
  </code></pre>
  
  <p>Now this example works perfectly fine. But when I try to use this to add code to make API for a machine learning mode.</p>
  
  <p>Below is the code the for the same.</p>
  
  <pre><code>from flask import Flask, abort, request,render_template, json, render_template_string
  
  from DataPreparationv4 import Data_Preprocess
  import numpy as np
  import pandas as pd
  import pickle
  from flask_jsonpify import jsonpify
  
  pd.options.mode.chained_assignment = None
  
  filename = 'CTA_Classification.pkl'
  loaded_model = pickle.load(open(filename, 'rb'))
  
  app = Flask(__name__)
  
  @app.route("/", methods=['GET'])
  def Predictions():
  
      Base_Data = pd.read_csv('Test.csv')
      DataSet1 = Data_Preprocess(Base_Data)
  
      [...]
      df_list = Predictions.values.tolist()
  
      return render_template('homev2.html', my_list=df_list)
  
  if __name__ == '__main__':
      app.run(debug = True)
  
  @app.route('/about/')
  def about():
          return render_template('about.html')
  if __name__ == '__main__':
      app.run(debug = True) 
  </code></pre>
  
  <p>Now, when I run this, I get the below error. I have even tried to change the return code to  <code>return render_template('homev2.html')</code> but with same error.</p>
  
  <blockquote>
    <p>werkzeug.routing.BuildError: Could not build url for endpoint 'home'. Did you mean 'about' instead?</p>
  </blockquote>
  
  <p>Below is the code revised code for home.html named as <strong>homev2.html</strong>:</p>
  
  <pre><code>&lt;!DOCTYPE html&gt;
  &lt;html&gt;
  &lt;body&gt;
  {% extends "layout.html" %}
  {% block content %}
  &lt;div class="home"&gt;
  &lt;h1&gt;Predictions Page&lt;/h1&gt;
  &lt;p&gt;&lt;h4&gt;Predictions&lt;/h4&gt;&lt;/p&gt;
  &lt;table&gt;
           &lt;tbody&gt;
           {# here we iterate over every item in our list#}
           {% for item in my_list %}
               &lt;tr&gt;&lt;td&gt;{{ item }}&lt;/td&gt;&lt;/tr&gt;
           {% endfor %}
           &lt;/tbody&gt;
   &lt;/table&gt;
  &lt;/div&gt;
  {% endblock %}
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p><strong>layout.html</strong></p>
  
  <pre><code>&lt;!DOCTYPE html&gt;
  &lt;html&gt;
   &lt;head&gt;
      &lt;title&gt;Flask app&lt;/title&gt;
      &lt;link rel="stylesheet" href="{{ url_for('static', filename='css/main.css') }}"&gt;
    &lt;/head&gt;
    &lt;body&gt;
      &lt;header&gt;
        &lt;div class="container"&gt;
          &lt;h1 class="logo"&gt;The web app&lt;/h1&gt;
          &lt;strong&gt;&lt;nav&gt;
            &lt;ul class="menu"&gt;
              &lt;li&gt;&lt;a href="{{ url_for('home') }}"&gt;Home&lt;/a&gt;&lt;/li&gt;
              &lt;li&gt;&lt;a href="{{ url_for('about') }}"&gt;About&lt;/a&gt;&lt;/li&gt;
            &lt;/ul&gt;
          &lt;/nav&gt;&lt;/strong&gt;
        &lt;/div&gt;
      &lt;/header&gt;
      &lt;div class="container"&gt;
        {% block content %}
        {% endblock %}
      &lt;/div&gt;
    &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>Below is the full traceback</p>
  
  <pre><code>[2018-07-08 23:05:35,225] ERROR in app: Exception on / [GET]
  Traceback (most recent call last):
    File "C:\Users\sudhir_kb\Continuum\anaconda3\lib\site-packages\flask\app.py", line 2292, in wsgi_app
      response = self.full_dispatch_request()
    File "C:\Users\sudhir_kb\Continuum\anaconda3\lib\site-packages\flask\app.py", line 1815, in full_dispatch_request
      rv = self.handle_user_exception(e)
    File "C:\Users\sudhir_kb\Continuum\anaconda3\lib\site-packages\flask\app.py", line 1718, in handle_user_exception
      reraise(exc_type, exc_value, tb)
    File "C:\Users\sudhir_kb\Continuum\anaconda3\lib\site-packages\flask\_compat.py", line 35, in reraise
      raise value
    File "C:\Users\sudhir_kb\Continuum\anaconda3\lib\site-packages\flask\app.py", line 1813, in full_dispatch_request
      rv = self.dispatch_request()
    File "C:\Users\sudhir_kb\Continuum\anaconda3\lib\site-packages\flask\app.py", line 1799, in dispatch_request
      return self.view_functions[rule.endpoint](**req.view_args)
    File "D:\Deploy\Predictions.py", line 51, in Predictions
      return render_template('homev2.html', my_list=df_list)
    File "C:\Users\sudhir_kb\Continuum\anaconda3\lib\site-packages\flask\templating.py", line 135, in render_template
      context, ctx.app)
    File "C:\Users\sudhir_kb\Continuum\anaconda3\lib\site-packages\flask\templating.py", line 117, in _render
      rv = template.render(context)
    File "C:\Users\sudhir_kb\Continuum\anaconda3\lib\site-packages\jinja2\asyncsupport.py", line 76, in render
      return original_render(self, *args, **kwargs)
    File "C:\Users\sudhir_kb\Continuum\anaconda3\lib\site-packages\jinja2\environment.py", line 1008, in render
      return self.environment.handle_exception(exc_info, True)
    File "C:\Users\sudhir_kb\Continuum\anaconda3\lib\site-packages\jinja2\environment.py", line 780, in handle_exception
      reraise(exc_type, exc_value, tb)
    File "C:\Users\sudhir_kb\Continuum\anaconda3\lib\site-packages\jinja2\_compat.py", line 37, in reraise
      raise value.with_traceback(tb)
    File "D:\Deploy\templates\homev2.html", line 4, in top-level template code
      {% extends "layout.html" %}
    File "D:\Deploy\templates\layout.html", line 13, in top-level template code
      &lt;li&gt;&lt;a href="{{ url_for('home') }}"&gt;Home&lt;/a&gt;&lt;/li&gt;
    File "C:\Users\sudhir_kb\Continuum\anaconda3\lib\site-packages\flask\helpers.py", line 356, in url_for
      return appctx.app.handle_url_build_error(error, endpoint, values)
    File "C:\Users\sudhir_kb\Continuum\anaconda3\lib\site-packages\flask\app.py", line 2061, in handle_url_build_error
      reraise(exc_type, exc_value, tb)
    File "C:\Users\sudhir_kb\Continuum\anaconda3\lib\site-packages\flask\_compat.py", line 35, in reraise
      raise value
    File "C:\Users\sudhir_kb\Continuum\anaconda3\lib\site-packages\flask\helpers.py", line 345, in url_for
      force_external=external)
    File "C:\Users\sudhir_kb\Continuum\anaconda3\lib\site-packages\werkzeug\routing.py", line 1776, in build
      raise BuildError(endpoint, values, method, self)
  werkzeug.routing.BuildError: Could not build url for endpoint 'home'. Did you mean 'about' instead?
  127.0.0.1 - - [08/Jul/2018 23:05:35] "[1m[35mGET / HTTP/1.1[0m" 500 -
  </code></pre>
  
  <p>I don't understand why I am getting an error when I add the code to display the predictions as that's is only change. Where am I going wrong.</p>
  
  <p>I am still a newbie and learning these concepts by researching in internet.</p>
  
  <p>I have searched and did not find a similar issue even though the error is same in many posts hence created this. If this is a duplicate, please guide me to the original post.</p>
  
  <p>Please help me in fixing this issue.</p>