Reputation: 4766
OK, so I have this code in the server side:
@app.route('/physical_graph')
@login_required
def physical_graph():
# Some code
return generate_graph_view()
If we click on the circular icon, we will get the link /physical_graph#physical.circular:
<a class="icon" href="/physical_graph#physical.circular">
<img src="{{url_for('static',filename='images/circular64x64.png')}}"
id="circular_icon" width="32" height="32" title="Circular layout"/>
</a>
My question is: how can I tell Flask what string is after the hash? I need this because the code in the comment depends on this string. I tried with stating the app.route as:
@app.route('/physical_graph#<some_string>')
but without success - it gives me Error 404.
Any ideas how to do this?
Upvotes: 2
Views: 811
Reputation: 58542
When you ajaxify it you need to pass physical.circle to the server. First is just a comment on the use of icon:
<!-- notice i change from icon -> graphIcon icon is too general -->
<!--a stylist would be angry at you for using icon -->
<a class="graphIcon" href="/physical_graph#physical.circular"> .. </a>
You have some options first would be to pass it in the data attribute, this would be placed somewhere in javascript (that only gets executed once).
jQuery("#circular_icon").click(function() {
$.ajax({
url:'/physical_graph',
data:{
'graph_type': 'physical_graph.circular'
},
'success':function(data){
//your function goes here.
}
})
} );
@app.route('/physical_graph')
@login_required
def physical_graph():
_type = request.args.get('graph_type')
Upvotes: 1