[Flask] [EXT] Re: render_template_string doesn't render

Patrick L Jones plj at mitre.org
Wed Aug 18 13:36:39 EDT 2021


	I'm using Chrome. I get the same result when I just return the string '<h1>PLEASE CLOSE THIS WINDOW</h1>' as using the render_template_string().  Chrome isn't recognizing it as html.  
	As I said it the start of this thread my flask get() method is being called by an OAUTH2 redirect.  Any idea how I would make Chrome understand that its getting back html instead of text?

Thank you,


-----Original Message-----
From: Flask <flask-bounces+plj=mitre.org at python.org> On Behalf Of Dennis Lee Bieber
Sent: Monday, August 16, 2021 12:53 PM
To: flask at python.org
Subject: Re: [Flask] [EXT] Re: render_template_string doesn't render

On Mon, 16 Aug 2021 12:32:15 +0000, Patrick L Jones <plj at mitre.org> declaimed the following:

>	I tried the suggestions:
>        return render_template_string("""
>        {% autoescape false %}
>        <h1>PLEASE CLOSE THIS WINDOW</h1>
>        {% endautoescape %}
>        """)
	Further reading indicates that autoescape would only apply to "variables" referenced within the template... And you don't have any of those. NOTE: from the Flask viewpoint "render" means replacing variables with their value, and applying conditional and looping constructs to create the resultant HTML. Translating HTML markup into visuals is the responsibility of the browser.

	In truth, there doesn't seem to be any need for render_template_string in your example... There is no template, just a string. You could just return the string as is.

	What browser are you using? Perhaps IT is treating the source as text rather than HTML (Check the page source as seen by your browser -- it could mean that you will, somewhere in the chain of calls, need to identify this as HTML to the browser).

	Wulfraed                 Dennis Lee Bieber         AF6VN
	wlfraed at ix.netcom.com    http://wlfraed.microdiversity.freeddns.org/

Flask mailing list
Flask at python.org

More information about the Flask mailing list