Why might this link not be working...?
<p>I'm rendering a bunch of posts on a page where a user can browse listings and click on one of them and be sent to a 'singles page' for more information on whatever product they clicked. This method works for every link EXCEPT for the first one. </p>

<p>Anytime I click on the very first link of the page, I get a <strong>Not Found: The requested URL was not found on the server. If you entered the URL manually please check your spelling and try again.</strong> error.</p>

<p>The logic I have in place for the HMTL/jinja is (everything is closed off properly, I'm cutting some unnecessary code for the sake of brevity):</p>

<pre><code>{% set i = 0 %}
   {% for row in data %}
      {% set i = i + 1 %}

                       &lt;a href="/iLike/{{ i }}"&gt;
                                &lt;li&gt;content&lt;/li&gt;
                       &lt;/a&gt;
</code></pre>

<p>and my python code:</p>

<pre><code>@app.route('/iLike/&lt;int:num&gt;', methods=['GET','POST'])
def single2(num):
  try:
    loc = session.get('loc')
    transType = session.get('transType')
    data = singlesQuery()


    return render_template('single.html', loc=loc,transType=transType,data=data[num-1])
except Exception as e:
    return (str(e))
</code></pre>

<p>There is no need to build URLs manually. The best way it to use flask's built-in function <a href="http://flask.pocoo.org/docs/0.11/api/#flask.url_for" rel="nofollow"><code>url_for</code></a>:</p>

<pre><code>{{url_for('single2', num=i)}}
</code></pre>

<p>There is also no need for calculating the <code>i</code> manually, becaue there is built-in <code>loop.index</code> and <code>loop.index0</code>:</p>

<pre><code>{% for row in data %}
    &lt;a href="{{url_for('single2', num=loop.index)}}"&gt;
</code></pre>

<p>I believe this should always create a valid URL.</p>

python flask jinja2