Search code examples
htmlflasktags

Flask app return string doesn't display <abc>


I tried to display a string on a webpage with this Flask code:

@app.route('/')
def index():
    return 'Variable can be of different types: string and <int>'

and got

Variable can be of different types: string and

without "<>". A way to fix it is to add a space between "<" and "int" like:

Variable can be of different types: string and < int >. 

Also I noticed that the space for the closing > as in "< int>" doesn't matter.

Other characters such as [int] and {int} have no such a problem. Why? tag related?


Solution

  • Yes, it is tags related, it gonna be shows up like this

    enter image description here

    If you use the less than (<) or greater than (>) signs in your text, the browser might mix them with tags.

    However, if you want to still display that, you can just do this enter image description here

    For more reference, here