Here is the code of python. I am trying to return the p variable to web page but on web page whole string is showing in one line
for k, v in sim_sorted:
if v >= 0.7 or str(q) in str(documents_clean[k]):
p = f"""News is Valid
similarity values: {v}
Headline: {documents_clean[k]}
Source: {df1.Link[k]}"""
break
elif v < 0.7 or str(q) not in str(documents_clean[k]):
p ="Remarks: News is Invalid"
break
return p
here is the HTML code:
{% if result %}
<center><strong>Prediction : {{result}}</strong></center>
{% endif %}
CodePudding user response:
I am assuming the p variable is going in the {{ result }}
. In that case, Jinja is going to take the string p, and replace the {{ result }}
with the string. This will in turn be rendered as HTML, so you need to treat the string as if it is HTML.
Try putting a line break tag '<br>
' after each line in the string, like this:
p = f"""News is Valid <br>
similarity values: {v}<br>
Headline: {documents_clean[k]} <br>
Source: {df1.Link[k]}<br>"""