From plj at mitre.org Fri Aug 13 14:48:55 2021 From: plj at mitre.org (Patrick L Jones) Date: Fri, 13 Aug 2021 18:48:55 +0000 Subject: [Flask] render_template_string doesn't render Message-ID: Greetings, I have the following: def get(self): return render_template_string('

PLEASE CLOSE THIS WINDOW

') When the following is called what is displayed in the browser is : '

PLEASE CLOSE THIS WINDOW

' It doesn't get rendered. I have tried various option as seen on the web, such as: return render_template_string('''

Hello, World!

''') It just displays the html, it doesn't render it. I have also tried render_template('pleaseclose.html'), it also just displays the html in the file and doesn't render it The way the get(self) is called is by a callback from an OAuth2 request. Any thoughts ? Thank you Pat -------------- next part -------------- An HTML attachment was scrubbed... URL: From plj at mitre.org Mon Aug 16 08:32:15 2021 From: plj at mitre.org (Patrick L Jones) Date: Mon, 16 Aug 2021 12:32:15 +0000 Subject: [Flask] [EXT] Re: render_template_string doesn't render In-Reply-To: <10879_1628890221_6116E469_10879_552_2_eqodhglcnuhsakfn7vpsdkvbbfcabds4de@4ax.com> References: <10879_1628890221_6116E469_10879_552_2_eqodhglcnuhsakfn7vpsdkvbbfcabds4de@4ax.com> Message-ID: Greetings, I tried the suggestions: return render_template_string(""" {% autoescape false %}

PLEASE CLOSE THIS WINDOW

{% endautoescape %} """) What was rendered on the page was: "\n \n

PLEASE CLOSE THIS WINDOW

\n \n " Any idea of what I'm doing wrong or how to make it render the string? Thank you, Pat -----Original Message----- From: Flask On Behalf Of Dennis Lee Bieber Sent: Friday, August 13, 2021 5:29 PM To: flask at python.org Subject: [EXT] Re: [Flask] render_template_string doesn't render On Fri, 13 Aug 2021 18:48:55 +0000, Patrick L Jones declaimed the following: >def get(self): > return render_template_string('

PLEASE CLOSE THIS WINDOW

') Per some documentation https://flask.palletsprojects.com/en/2.0.x/templating/ """ Unless customized, Jinja2 is configured by Flask as follows: autoescaping is enabled for all templates ending in .html, .htm, .xml as well as .xhtml when using render_template(). autoescaping is enabled for all strings when using render_template_string(). a template has the ability to opt in/out autoescaping with the {% autoescape %} tag. """ """ Autoescaping is the concept of automatically escaping special characters for you. Special characters in the sense of HTML (or XML, and thus XHTML) are &, >, <, " as well as '. Because these characters carry specific meanings in documents on their own you have to replace them by so called ?entities? if you want to use them for text. Not doing so would not only cause user frustration by the inability to use these characters in text, but can also lead to security problems. (see Cross-Site Scripting (XSS)) Sometimes however you will need to disable autoescaping in templates. This can be the case if you want to explicitly inject HTML into pages, for example if they come from a system that generates secure HTML like a markdown to HTML converter. """ """ To disable the autoescape system in templates, you can use the {% autoescape %} block: {% autoescape false %}

autoescaping is disabled here

{{ will_not_be_escaped }} {% endautoescape %} """ -- Wulfraed Dennis Lee Bieber AF6VN wlfraed at ix.netcom.com http://wlfraed.microdiversity.freeddns.org/ _______________________________________________ Flask mailing list Flask at python.org https://mail.python.org/mailman/listinfo/flask From arj.python at gmail.com Tue Aug 17 06:45:53 2021 From: arj.python at gmail.com (Abdur-Rahmaan Janhangeer) Date: Tue, 17 Aug 2021 14:45:53 +0400 Subject: [Flask] FlaskCon's Call For Volunteers Is On Message-ID: Greetings list, As preparations for FlaskCon intensifies, the call for volunteers goes live: https://twitter.com/FlaskCon/status/1427542892642410502?s=20 You can also chip in directly here: https://docs.google.com/forms/d/e/1FAIpQLSfsHNBcclWSmVkk4LDD_EnlhrlKdWlGOakdwbt5PbaFklpHAA/viewform According to previsions, it might be the last Python conf of the year! Kind Regards, Abdur-Rahmaan Janhangeer about | blog github Mauritius -------------- next part -------------- An HTML attachment was scrubbed... URL: From plj at mitre.org Wed Aug 18 13:36:39 2021 From: plj at mitre.org (Patrick L Jones) Date: Wed, 18 Aug 2021 17:36:39 +0000 Subject: [Flask] [EXT] Re: render_template_string doesn't render In-Reply-To: References: <10879_1628890221_6116E469_10879_552_2_eqodhglcnuhsakfn7vpsdkvbbfcabds4de@4ax.com> <10879_1628890221_6116E469_10879_552_2_eqodhglcnuhsakfn7vpsdkvbbfcabds4de-e09XROE/p8c@public.gmane.org> Message-ID: Greetings, I'm using Chrome. I get the same result when I just return the string '

PLEASE CLOSE THIS WINDOW

' 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, Pat -----Original Message----- From: Flask 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 declaimed the following: >Greetings, > > I tried the suggestions: > return render_template_string(""" > {% autoescape false %} >

PLEASE CLOSE THIS WINDOW

> {% 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 https://mail.python.org/mailman/listinfo/flask From plj at mitre.org Thu Aug 19 08:39:47 2021 From: plj at mitre.org (Patrick L Jones) Date: Thu, 19 Aug 2021 12:39:47 +0000 Subject: [Flask] [EXT] Re: render_template_string doesn't render In-Reply-To: <1ljqhgdvcapbei63vat63r1q3r98knaska@4ax.com> References: <10879_1628890221_6116E469_10879_552_2_eqodhglcnuhsakfn7vpsdkvbbfcabds4de@4ax.com> <10879_1628890221_6116E469_10879_552_2_eqodhglcnuhsakfn7vpsdkvbbfcabds4de-e09XROE/p8c@public.gmane.org> <1ljqhgdvcapbei63vat63r1q3r98knaska@4ax.com> Message-ID: Greetings, Thank all of you who helped. I got it working as follows: def get(self): return Response('

PLEASE CLOSE THIS WINDOW

', 200, mimetype='text/html') thanx again Pat -----Original Message----- From: Flask On Behalf Of Dennis Lee Bieber Sent: Wednesday, August 18, 2021 2:55 PM To: flask at python.org Subject: Re: [Flask] [EXT] Re: render_template_string doesn't render On Wed, 18 Aug 2021 17:36:39 +0000, Patrick L Jones declaimed the following: > > I'm using Chrome. I get the same result when I just return the string '

PLEASE CLOSE THIS WINDOW

' 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? > I don't normally use Chrome, so I don't know what capabilities it provides (my closest exposure is the version on my cell-phone -- and that one seems to be optimized to push advertising at me over actual content, and doesn't support things like ad-block and no-script). Does it allow you to display the raw page source? If it does, what does that page look like? {Hmmm, disgusting -- even the U-verse modem /status/ page is over 400 lines of HTML} https://flask.palletsprojects.com/en/2.0.x/api/#response-objects indicates that the HTML mimetype is the default, but possibly something in your environment is overriding that -- however, (making an assumption here) https://pythonhosted.org/Flask-OAuth/ seems to reverse the scheme some in that it /sends/ "requests" -- and those requests default to either "urlencoded" or "json"; if one is transferring something else, one needs to provide "content_type" argument. > >-----Original Message----- >From: Flask On Behalf Of >Dennis Lee Bieber Hmmm, apparently another moderated forum made available on gmane's NNTP gateway. Apologies to the admins then -- I much favor my newsreader for such forums as it manages threads and short term history much cleaner than my mail client would (autopurging old messages, distributing to a group-specific "folder" rather than requiring me to create filters, and fetching messages on my schedule -- vs either piecemeal during the day in my mail client, or one bundle per day that then needs to be burst to be reasonably usable [which my mail client can not do; my news client has the ability, but I'd have to create a distinct email address to separate forum posts from my regular email addresses]). At least the post did get accepted. I think the Firebird group I'm tracking is just round-filing any responses I make. -- Wulfraed Dennis Lee Bieber AF6VN wlfraed at ix.netcom.com http://wlfraed.microdiversity.freeddns.org/ _______________________________________________ Flask mailing list Flask at python.org https://mail.python.org/mailman/listinfo/flask