Permalink
Browse files

Add index page

  • Loading branch information...
greyli committed Dec 16, 2018
1 parent d6f9f73 commit 17b579d693cb3cfd2cc0e622d955ea1459f7406b
Showing with 36 additions and 3 deletions.
  1. +17 −3 app.py
  2. +19 −0 templates/index.html
20 app.py
@@ -1,8 +1,22 @@
# -*- coding: utf-8 -*-
from flask import Flask
from flask import Flask, render_template
app = Flask(__name__)

name = 'Grey Li'
movies = [
{'title': 'My Neighbor Totoro', 'year': '1988'},
{'title': 'Dead Poets Society', 'year': '1989'},
{'title': 'A Perfect World', 'year': '1993'},
{'title': 'Leon', 'year': '1994'},
{'title': 'Mahjong', 'year': '1996'},
{'title': 'Swallowtail Butterfly', 'year': '1996'},
{'title': 'King of Comedy', 'year': '1999'},
{'title': 'Devils on the Doorstep', 'year': '1999'},
{'title': 'WALL-E', 'year': '2008'},
{'title': 'The Pork of Music', 'year': '2012'},
]


@app.route('/')
def hello():
return 'Welcome to My Watchlist!'
def index():
return render_template('index.html', name=name, movies=movies)
@@ -0,0 +1,19 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>{{ name }}'s Watchlist</title>
</head>
<body>
<h2>{{ name }}'s Watchlist</h2>
<p>{{ movies|length }} Titles</p>
<ul>
{% for movie in movies %}
<li>{{ movie.title }} - {{ movie.year }}</li>
{% endfor %}
</ul>
<footer>
<small>&copy; 2018 <a href="http://helloflask.com/tutorial">HelloFlask</a></small>
</footer>
</body>
</html>

0 comments on commit 17b579d

Please sign in to comment.