Home > front end >  How to print variable present in python with the help of html?
How to print variable present in python with the help of html?

Time:02-07

I've written some code for deep learning text summarization, and I'm trying to render the template using the Flask library. I'm unable to see the results. The python code can be found below.

    text = ' '.join([summ['summary_text'] for summ in res])
    print(text)
return render_template('result.html', prediction=text)

I'm trying to print the prediction variable which is present in the above code. Below is the html code

<!DOCTYPE html>
<html>
<head>
    <title></title>
    <link rel="stylesheet" type="text/css" href="{{ url_for('static', filename='css/styles.css') }}">
</head>
<body>

    <header>
        <div >
        <div id="brandname">
            Deep Learning App
        </div>
        <h2>Summarized text</h2>
        
    </div>
    </header>
    <p style="color:blue;font-size:20;text-align: center;"><b>Result for Text</b></p>
    <div >


    
    <p><strong>{prediction}</strong></p>

    </div>

</body>
</html>

Below is output image

enter image description here

Can anyone help me how to display text present in prediction variable on web page?

CodePudding user response:

You need double curly braces

<p><strong>{{ prediction }}</strong></p>
  •  Tags:  
  • Related