Giter VIP home page Giter VIP logo

Comments (19)

GoogleCodeExporter avatar GoogleCodeExporter commented on July 18, 2024
There is nowhere near enough information in this report for me to tell you 
anything useful.  *How* are you trying to use it with Flask?  *What* error are 
you getting?  Unless you show me some code I can't help you at all.

Original comment by [email protected] on 14 Dec 2013 at 11:42

from prettytable.

GoogleCodeExporter avatar GoogleCodeExporter commented on July 18, 2024
The module is just returning a string without any form of formatting 

Original comment by pilotkid2011 on 14 Dec 2013 at 11:44

from prettytable.

GoogleCodeExporter avatar GoogleCodeExporter commented on July 18, 2024
How are you using it?  Show me code.

Original comment by [email protected] on 14 Dec 2013 at 11:53

from prettytable.

GoogleCodeExporter avatar GoogleCodeExporter commented on July 18, 2024
def hello_admins(username):
    from prettytable import *

    x = PrettyTable(["Name","Phone","Yardage"])
    x.add_row(['John',"7193382296","27"])
    x.add_row(['Phil',"7195926682","16"])
        x.get_string(attributes = {"class": "foo"})
    return render_template("allshooters.html",tbl=x )

Original comment by pilotkid2011 on 14 Dec 2013 at 11:56

from prettytable.

GoogleCodeExporter avatar GoogleCodeExporter commented on July 18, 2024
Try replacing "get_string" with "get_html_string" and see if that works.

Original comment by [email protected] on 14 Dec 2013 at 11:58

from prettytable.

GoogleCodeExporter avatar GoogleCodeExporter commented on July 18, 2024
[deleted comment]

from prettytable.

GoogleCodeExporter avatar GoogleCodeExporter commented on July 18, 2024
I get the same string result... :/

My html code is 

{% block contents %}
<p>a</p>
{% for message in get_flashed_messages() %}
        <div class = flash>

          {{message}}

        </div>
    {% endfor %}
{{tbl}}

{% endblock %}

Original comment by pilotkid2011 on 15 Dec 2013 at 12:02

from prettytable.

GoogleCodeExporter avatar GoogleCodeExporter commented on July 18, 2024
Oh!  That's because you're just passing the PrettyTable object x to the Flask 
rendering system.  You need to actually pass the string containing the HTML 
code that PrettyTable generates.  Get rid of the line:

x.get_string(attributes = {"class": "foo"})

and change the final line to:

return render_template("allshooters.html",tbl=x.get_html_string(attributes = 
{"class": "foo"}))

(or, alternatively, store the output of get_html_string in an intermediary 
variable and pass that to render_template).

Original comment by [email protected] on 15 Dec 2013 at 12:03

from prettytable.

GoogleCodeExporter avatar GoogleCodeExporter commented on July 18, 2024
Yay it somewhat worked now I am getting the result as actual html" <table 
class="foo"> <tr> <th>Name</th> <th>Phone</th> <th>Yardage</th> </tr> <tr> 
<td>John</td> <td>7193382296</td> <td>27</td> </tr> <tr> <td>Phil</td> 
<td>7195926682</td> <td>16</td> </tr> </table>"  but i can figure it out.. 
unless you have any quick reconmendations

Original comment by pilotkid2011 on 15 Dec 2013 at 12:06

from prettytable.

GoogleCodeExporter avatar GoogleCodeExporter commented on July 18, 2024
This is probably something to do with Flask, automatically escaping HTML input 
to templates in order to avoid CSS attacks and similar things.  I vaguely 
recall having to deal with something like that in the past, but I don't know 
how to fix it off the top of my head.  You should be able to find something in 
the Flask docs easily enough.

Original comment by [email protected] on 15 Dec 2013 at 12:08

from prettytable.

GoogleCodeExporter avatar GoogleCodeExporter commented on July 18, 2024
Ok also may I give you a small piece of constructive criticism with your 
tutorial?

Original comment by pilotkid2011 on 15 Dec 2013 at 12:15

from prettytable.

GoogleCodeExporter avatar GoogleCodeExporter commented on July 18, 2024
Yes, of course!  Please do.

Original comment by [email protected] on 15 Dec 2013 at 1:32

from prettytable.

GoogleCodeExporter avatar GoogleCodeExporter commented on July 18, 2024
There were times when I was reading the tutorial where I was confused on what 
you meant I also thought there could be more code but other than that I love 
this module I've used it on 3 other projects (I am making my first site now) 
but it is a great module it just needs a more coded and better worded tutorial 
just to help others 

Original comment by pilotkid2011 on 15 Dec 2013 at 4:17

from prettytable.

GoogleCodeExporter avatar GoogleCodeExporter commented on July 18, 2024
Also I am sorry about this but I cannot figure out the getting the table to 
work without getting rid of the style sheet

Original comment by pilotkid2011 on 15 Dec 2013 at 4:27

from prettytable.

GoogleCodeExporter avatar GoogleCodeExporter commented on July 18, 2024
Try replacing "{{tbl}}" in your template with "{{tbl|safe}}" and see if that 
fixes it.

Original comment by [email protected] on 15 Dec 2013 at 4:47

from prettytable.

GoogleCodeExporter avatar GoogleCodeExporter commented on July 18, 2024
I LOVE YOU!!!!!!

Original comment by pilotkid2011 on 15 Dec 2013 at 4:49

from prettytable.

GoogleCodeExporter avatar GoogleCodeExporter commented on July 18, 2024
Glad it worked.  You should make sure you understand why Flask automatically 
escapes HTML by default, and understand when it is and isn't safe to use the 
"safe" filter.  Maybe read https://en.wikipedia.org/wiki/Cross-site_scripting.

Thanks for your feedback on the tutorial.  Next time I update it I'll try 
adding some more example code.

Original comment by [email protected] on 15 Dec 2013 at 5:38

from prettytable.

GoogleCodeExporter avatar GoogleCodeExporter commented on July 18, 2024
Thank you I am am kinda learning the whole flask this but my site is pretty 
cool 

Original comment by pilotkid2011 on 15 Dec 2013 at 5:39

from prettytable.

GoogleCodeExporter avatar GoogleCodeExporter commented on July 18, 2024

Original comment by [email protected] on 15 Dec 2013 at 5:56

  • Changed state: Done

from prettytable.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.