Showing element in html with flask and BeautifulSoup 3 and Python 2.7.8
Question: The question is: I have my @app.route and the relative def() which shows a
list of urls taken from "<http://annotaria.web.cs.unibo.it/documents/>". How
can i show this urls in a html format? When i click
`http://localhost:5000/articoli` i'd like to show a list of my urls.

Thank you very much

    
    
    @app.route('/articoli', methods=['GET'])
    def lista_articoli():
    lista = []
    import urllib2
    from bs4 import BeautifulSoup
    url = urllib2.urlopen`http://annotaria.web.cs.unibo.it/documents/.read()`
    soup = BeautifulSoup(url)
    for row in soup.findAll('a'):
        if row.parent.name == 'td':
            if row["href"] :
                myArticle = row["href"]
                if '.html' in myArticle:
                    print myArticle
                    lista.append({'url':myArticle}) }
    


Answer: To do this, have your function return the `render_template` method, to which
you'll pass your URL list.

At the end of your function, try:

    
    
    render_template("articoli.html", lista = lista)
    

You'll need to have a corresponding `articoli.html` template saved in a
_templates_ folder, which in turn should be in the same location as your
Python script. Within the HTML of the template, you'll need to designate where
Flask/Jinja puts the URL list you've provided, which in this case would be
`{{lista}}`.

This is outlined in the [Flask
documentation](http://flask.pocoo.org/docs/0.10/quickstart/).

