How can I get values from python file to my html?
<p>I'm trying to get values from my phython file to my html. </p>

<p>Here's my form: </p>

<pre><code>&lt;div class="form-group "&gt;
    &lt;label class="col-sm-3 col-sm-3 control-label"&gt;Direccion IP: &lt;/label&gt;
    &lt;div class="col-sm-9"&gt;
        &lt;input type="text" class="form-control" value="{{ address }}" &gt;
    &lt;/div&gt;
&lt;/div&gt;
</code></pre>

<p>Here's my python file: </p>

<pre><code>def getinterfaces():
    with open('/etc/network/interfaces', 'r+') as f:
        for line in f:
            found_address = line.find('address')
            if found_address != -1:
                address = line[found_address+len('address:'):]
                print 'Address: ', address
            return address
</code></pre>

<p>I tried with "FLASK" but nothing worked.. </p>

<blockquote>
  <p>I think my problem is in my path , because my project is in
  "project/app/Mensajeria/views.py", my html is in:
  "project/app/templates/test.html"</p>
</blockquote>

<p>I'm importing Flask and everything, I have flask installed, I tried to reinstalled but nothing worked...</p>

<p>If you're sending the data to be served up on a webpage, using the HTML template, how about something like this?</p>

<pre><code>@app.route('/test')
def showPage():
    # your code here
    address = # however you assign it
    return render_template('test.html', address=address)
</code></pre>

<p>In order to use a variable inside <code>{{}}</code> in a template, you'll have to pass that variable to the template, such as here with <code>return render_template('test.html', address=address)</code>.  </p>

<p>If you need <code>address</code> to contain many things you can always send it as a <code>list</code> or <code>dict</code> and extract the individual variables you need in your template with <code>jinja</code>.  For example, if you need multiple <code>&lt;div&gt;</code> elements each containing an address:</p>

<h3>python file</h3>

<pre><code>@app.route('/test')
def showPage():
    # your code here
    addresses = # however you assign it
    return render_template('test.html', addresses=addresses)
</code></pre>

<h3>test.html</h3>

<pre><code>{% for address in addresses %}
    &lt;div class="form-group "&gt;
        &lt;label class="col-sm-3 col-sm-3 control-label"&gt;Direccion IP: &lt;/label&gt;
        &lt;div class="col-sm-9"&gt;
            &lt;input type="text" class="form-control" value="{{ address }}" &gt;
        &lt;/div&gt;
    &lt;/div&gt;
{% endfor %}
</code></pre>

python html python-2.7 flask debian