[Python] How to decode a url string in a flask template

Discussão em 'Python' iniciado por Stack, Maio 26, 2025.

  1. Stack

    Stack Membro Participativo

    I am using flask.

    In my template I used this to encode a string.

    encodeURIComponent(mytag)


    Now I want to decode in another template.
    Where is what the string looks like.

    %26lt%3B!--Afff%20Tracking%20Tag--%26gt%3B%0A%26lt%3Bimg%20src%3D%22http%3A%2F%2Fcm.g.doubleclick.net%2Fpixel%3F%0Agggg_nid%3Dhff%26gggg_cm%26avid%3David3966173574%26campaign_id%3Dundefined%22%20%2F%26gt%3B


    In the template how do I decode the string?

    {% for crid, object in tag_handler.iteritems() %}
    <script>var x = decodeURI("{{object['tag_display']}}"); alert(x);</script>
    <div id="tagBox" style="display: block;width: 700px">
    <pre class="prettyprint">
    <code class="language-html">
    {{object['tag_display']}}
    </code>
    </pre>
    </div>

    {% endfor %}


    I am using google pretty to display the string.

    Continue reading...

Compartilhe esta Página