i'm working with a flask to make a dashborard, in my project i have a script inside the flask app that generates the html code. and my question is how to use url_for to create the dynamic routing is this case, here is my code:
rec+='<td><a href="url_for(case,id='+row['ID']+'" id="'+str(row['ID'])+'" >More</a></td>'
Any ideas how to make it work and thank you in advance.
You should use {{ }}
enclose the url_for
statement.
rec += '<td><a href="{{ url_for(case, id=' + str(row['ID']) + ') }}">More</a></td>'
or use format string(more readable):
rec += '<td><a href="{{ url_for(case, id={}) }}">More</a></td>'.format(row['ID'])
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.