MCPcopy
hub / github.com/pallets/werkzeug / index

Function index

examples/plnt/views.py:16–28  ·  view source on GitHub ↗

Show the index page or any an offset of it.

(request, page)

Source from the content-addressed store, hash-verified

14@expose("/", defaults={"page": 1})
15@expose("/page/<int:page>")
16def index(request, page):
17 """Show the index page or any an offset of it."""
18 days = []
19 days_found = set()
20 query = Entry.query.order_by(Entry.pub_date.desc())
21 pagination = Pagination(query, PER_PAGE, page, "index")
22 for entry in pagination.entries:
23 day = date(*entry.pub_date.timetuple()[:3])
24 if day not in days_found:
25 days_found.add(day)
26 days.append({"date": day, "entries": []})
27 days[-1]["entries"].append(entry)
28 return render_template("index.html", days=days, pagination=pagination)
29
30
31@expose("/about")

Callers

nothing calls this directly

Calls 4

appendMethod · 0.80
PaginationClass · 0.70
render_templateFunction · 0.70
addMethod · 0.45

Tested by

no test coverage detected