Skip to content Skip to sidebar Skip to footer

How To Route Non-ascii Urls In Flask Python

Good afternoon, everyone! I have a problem with the routing my URL adress to Flask, precisely with running it in web-browser. All I want is to transfer the sharp symbol '#' and so

Solution 1:

You have to use %23 instead of #, because the hash symbol marks a fragment in a URL. Wikipedia

So the actual URL app.route is getting is /hashtag/

It seems to be impossible to get the content after #. See this.

Solution 2:

Try to decode your url before passing it to your view methods, this way:

@app.route('/hashtags/<names>'.encode('utf-8'), methods=['GET'])

Post a Comment for "How To Route Non-ascii Urls In Flask Python"