I have a dictionary with two dictionaries inside, with key-value pairs. I am trying to get the URL dynamically so that, when I display a bulletlist of dict names, I click them and I get a page with the related key-value pairs. So that suppose I have
cities = { 'Moskow': {'Russia':'RU'}, 'London': {'United Kingdom':'UK'}
On the index.html page is displayed:
- Moskow
- London
I click on Moskow and I get
- Russia, RU
But when I click on London I get
- United Kingdom, UK
I tried using url_for in index.html:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>{{ title }}</title>
</head>
<body>
<h1>Cities</h1>
<ul>
{% for city, city_info in cities.items(): %}
<li><a href={{url_for({{city}})}}>{{city}}</a></li>
{% endfor %}
</ul>
</body>
</html>
And route is
@app.route('/')
@app.route('/index')
def index():
citydict = cities
return render_template('index.html', title='Welcome', cities=citydict)
@app.route('/city')
def city():
citydict = cities
return render_template('cities.html', title='Welcome', cities=citydict)
But it doesn't work