[Flask] SVG Viewer Problem

Federico Delgado Doyle fededelgado at outlook.com
Thu Aug 27 05:02:16 CEST 2015


Oh, good then it was only issue number one, the escaping.
Please check the jinja2 documentation about "|safe" it is specially important to do so because it implies some security considerations. You are now going to push raw content to your html.
http://jinja.pocoo.org/docs/dev/templates/#safe
Federico
> Date: Thu, 27 Aug 2015 01:57:58 +0530
> Subject: Re: [Flask] SVG Viewer Problem
> From: arsh840 at gmail.com
> To: fededelgado at outlook.com
> 
> On Mon, Aug 24, 2015 at 6:19 AM, Federico Delgado Doyle
> <fededelgado at outlook.com> wrote:
> >
> > Hi Great Avenger,
> >
> > I have not used that file browser. But from a fast inspection I see that the file content is going to be escaped. That is one thing. The other one is, the SVG is not being requested as an image/svg+xml image so I don't thing that the browser is going to show it. The template says:
> >
> > <div class="row">
> > <div style="white-space:pre;">{{ text }}</div>
> > </div>
> >
> > Maybe you can try to render differently according to the type of file. For example if extension is a kind of image, >create a view_image action that renders differently.
> 
> Hi Federico and Everyone.
> 
> Thanks for reply I am able to solve it.
> I just added
> 
> {{text|safe}} in my html file and it worked. :)
> 
> As Python code is as follows:
> 
> http://pastebin.com/7sNgJgQ9
> 
> As only using {{text}} does not work but {{text|safe}} does work, What
> "safe" keyword stands for?
> 
> By the way I got it from following:
> 
> http://stackoverflow.com/questions/25195290/generating-dynamic-pygal-chart-in-flask
> 
> -- 
> 
> Thanks
> Arshpreet Singh
> 
> I am Sikh boy, Learning by doing and Learning by teaching is my religion.
> ------------------------------------------------------------------------------
> Slashdot TV.
> Video for Nerds.  Stuff that matters.
> http://tv.slashdot.org/
 		 	   		  
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/flask/attachments/20150826/00840bee/attachment.html>


More information about the Flask mailing list