Forums

html renders jinja code as html

Hi everybody,

I'm kind of nooby and having an issue with html and jinja, it seems that it just renders the jinja code as html. I've tried changing the code but i just can't get it to work.

This is what it get's render

flask_app.py

from flask import Flask, render_template
#from flask_bootstrap import Bootstrap

app = Flask(__name__)
app.config['SECRET_KEY'] = 'test'
#bootstrap = Bootstrap(app)

@app.route('/')
def index():
    #if 'username' in session:
    return render_template('index.html', my_string="Wheeeee!", my_list=[0,1,2,3,4,5])

index.html

<!DOCTYPE html>
<html>
  <head>
    <title>Flask Template Example</title>
  </head>
  <body>
      <p>My string: {{my_string}}</p>
      <p>Value from the list: {{my_list[3]}}</p>
      <p>Loop through the list:</p>
      <ul>
        {% for n in my_list %}
        <li>{{n}}</li>
        {% endfor %}
      </ul>
  </body>
</html>

Thanks!

solved

Glad you worked it out -- what turned out to be the problem?

How did u fix this issue?

As the OP is a deleted user, I wouldn't expect an answer...