title: flask View function mapping is overwriting an existing endpoint function: type
body: <p>I recently purchased <a href="http://www.realpython.com/" rel="noreferrer">RealPython</a> to learn about Python and web development. However, I have ran into a road block that I think is a Python configuration issue on my machine. Any help would be much obliged. </p>
  
  <p>So I have a Flask document called app.py similar to <a href="https://github.com/atrueresistance/RealPython/blob/master/flask-hello-world/app.py" rel="noreferrer">RealPython's github app.py</a></p>
  
  <pre><code># --- Flask Hello World ---#
  
  # import the Flask class from the flask module
  from flask import Flask
  
  # create the application object
  app = Flask(__name__)
  
  # use decorators to link the function to a url
  @app.route("/")
  @app.route("/hello")
  
  # define the view using a function, which returns a string
  def hello_world():
      return "Hello, World!"
  
  # dynamic route
  @app.route("/test/&lt;search_query&gt;")
  def search(search_query):
      return search_query
  
  # dynamic route with an int type
  @app.route("/integer/&lt;int:value&gt;")
  def type(value):
      print value + 1
      return "correct"
  
  # dynamic route with an float type
  @app.route("/float/&lt;float:value&gt;")
  def type(value):
      print value + 1
      return "correct"
  
  # dynamic route that accepts slashes
  @app.route("/path/&lt;path:value&gt;")
  def type(value):
      print value
      return "correct"
  
  
  
  # start the development server using the run() method
  if __name__ == "__main__":
      app.run()
  </code></pre>
  
  <p>I unfortunately receive this error when trying to run the app:</p>
  
  <pre><code>machine:flask-hello-world machine$ source env/bin/activate
  (env)machine:flask-hello-world machine$ python app.py
  Traceback (most recent call last):
    File "app.py", line 29, in &lt;module&gt;
      @app.route("/float/&lt;float:value&gt;")
    File "/Volumes/disk2/Home/Library/RealPython/flask-hello-world/env/lib/python2.7/site-packages/flask/app.py", line 1013, in decorator
      self.add_url_rule(rule, endpoint, f, **options)
    File "/Volumes/disk2/Home/Library/RealPython/flask-hello-world/env/lib/python2.7/site-packages/flask/app.py", line 62, in wrapper_func
      return f(self, *args, **kwargs)
    File "/Volumes/disk2/Home/Library/RealPython/flask-hello-world/env/lib/python2.7/site-packages/flask/app.py", line 984, in add_url_rule
      'existing endpoint function: %s' % endpoint)
  AssertionError: View function mapping is overwriting an existing endpoint function: type
  </code></pre>
  
  <p>Pip freeze gives these as requirements for virtualenv <code>env</code>. Python 2.7 is what is installed.</p>
  
  <pre><code>Flask==0.10.1
  Jinja2==2.7.3
  MarkupSafe==0.23
  Werkzeug==0.9.6
  itsdangerous==0.24
  wsgiref==0.1.2
  </code></pre>
  
  <hr>
  
  <p>The only way I've been able to get the code to run is by changing def type. One should not have to do this though... </p>
  
  <pre><code># dynamic route with an int type
  @app.route("/integer/&lt;int:value&gt;")
  def type(value):
      print value + 1
      return "correct"
  
  # dynamic route with an float type
  # change to type1 so dev server will spool up
  @app.route("/float/&lt;float:value&gt;")
  def type1(value):
      print value + 1
      return "correct"
  
  # dynamic route that accepts slashes
  # change to type2 so dev server will spool up
  @app.route("/path/&lt;path:value&gt;")
  def type2(value):
      print value
      return "correct"
  </code></pre>
  
  <hr>
  
  <h2><a href="https://github.com/atrueresistance/RealPython/blob/master/flask-hello-world/app.py" rel="noreferrer">Solution</a></h2>