Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- @app.route("/page", methods=["GET","POST"])
- def page():
- users = {
- "data":[
- {
- “Name”:”Tom”,
- “Age”:”21”
- },
- {
- “Name”:”John”,
- “Age”:”40”
- },
- {
- “Name”:”Juddy”,
- “Age”:”37”
- },
- {
- “Name”:”Kei”,
- “Age”:”46”
- },
- {
- “Name”:”Wu”,
- “Age”:”12”
- },
- {“Name”:”Rey”,
- “Age”:”47”
- },
- {
- “Name”:”Boo”,
- “Age”:”25”
- },
- {
- “Name”:”Cho”,
- “Age”:”48”
- }
- ],
- “Date”:”20180403”
- }
- users = users["data"]
- page = request.args.get(get_page_parameter(), type=int, default=5)
- pagination = Pagination(page=page, total=len(users), search=search)
- return render_template(“index.html", json=users,pagination=pagination)
- <div>
- {% for i in range(json|length) %}
- <div>
- <h3>{{ json[i]['Name'] }}</h3>
- <h3>{{ json[i]['Age'] }}</h3>
- </div>
- {% endfor %}
- </div>
- {{ pagination.info }}
- {{ pagination.links }}
- page = request.args.get(get_page_parameter(), type=int, default=0)
- users = users["data"]
- page_users = users[p*5: p*5 + 5]
- return render_template(“index.html", json=page_users, pagination=pagination)
Add Comment
Please, Sign In to add comment