Skip to content

Instantly share code, notes, and snippets.

@raj454raj
Created March 13, 2017 10:26
Show Gist options
  • Save raj454raj/236adc972da89bcff961e9b6de0bd52e to your computer and use it in GitHub Desktop.
Save raj454raj/236adc972da89bcff961e9b6de0bd52e to your computer and use it in GitHub Desktop.
<!-- File: layout.html -->
<!DOCTYPE html>
<html>
<body>
<h1>Hello {{ name }}!</h1>
<h1>Age {{ age }}!</h1>
{% for i in range(5) %}
<h2> {{ i }} </h2>
{% endfor %}
</body>
</html>
@raj454raj
Copy link
Author

Updated layout.html

<!-- File: layout.html -->
<!DOCTYPE html>
<html>
   <body>
      <h1>Hello {{ name }}!</h1>
      <h1>Age {{ age }}!</h1>
      <table border="1">
      {% for user in user_list %}
        <tr>
          <td>{{  user[0] }}</td>
          <td> {{ user[1] }}</td>
        </tr>
      {% endfor %}
      </table>
   </body>
</html>

@raj454raj
Copy link
Author

server.py

from flask import Flask, render_template
app = Flask(__name__)

@app.route('/hello/<user>')
def hello_name(user):
   l = [("Raj", 21), ("harshit", "20"), ("Hitesh", 25)]
   return render_template('layout.html', name=user, age=21, user_list=l)

if __name__ == '__main__':
   app.run(debug = True)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment