Guest User

Untitled

a guest
Jun 19th, 2018
110
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.59 KB | None | 0 0
  1. @app.route("/page", methods=["GET","POST"])
  2. def page():
  3.  
  4. users = {
  5. "data":[
  6. {
  7. “Name”:”Tom”,
  8. “Age”:”21”
  9. },
  10. {
  11. “Name”:”John”,
  12. “Age”:”40”
  13. },
  14. {
  15. “Name”:”Juddy”,
  16. “Age”:”37”
  17. },
  18. {
  19. “Name”:”Kei”,
  20. “Age”:”46”
  21. },
  22. {
  23. “Name”:”Wu”,
  24. “Age”:”12”
  25. },
  26. {“Name”:”Rey”,
  27. “Age”:”47”
  28. },
  29. {
  30. “Name”:”Boo”,
  31. “Age”:”25”
  32. },
  33. {
  34. “Name”:”Cho”,
  35. “Age”:”48”
  36. }
  37. ],
  38. “Date”:”20180403”
  39. }
  40.  
  41. users = users["data"]
  42.  
  43.  
  44. page = request.args.get(get_page_parameter(), type=int, default=5)
  45. pagination = Pagination(page=page, total=len(users), search=search)
  46.  
  47.  
  48. return render_template(“index.html", json=users,pagination=pagination)
  49.  
  50. <div>
  51. {% for i in range(json|length) %}
  52. <div>
  53. <h3>{{ json[i]['Name'] }}</h3>
  54. <h3>{{ json[i]['Age'] }}</h3>
  55. </div>
  56. {% endfor %}
  57. </div>
  58.  
  59. {{ pagination.info }}
  60. {{ pagination.links }}
  61.  
  62. page = request.args.get(get_page_parameter(), type=int, default=0)
  63.  
  64. users = users["data"]
  65. page_users = users[p*5: p*5 + 5]
  66.  
  67. return render_template(“index.html", json=page_users, pagination=pagination)
Add Comment
Please, Sign In to add comment