Skip to content

Commit

Permalink
Include the pagination template
Browse files Browse the repository at this point in the history
  • Loading branch information
willu47 committed Dec 19, 2024
1 parent 896c494 commit 7a6443e
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 2 deletions.
24 changes: 24 additions & 0 deletions app/templates/pagination.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<div class="row">
<nav aria-label="Page navigation example">
<ul class="pagination justify-content-center">
{% if not skip == 0%}
<li class="page-item"><a class="page-link" href="?limit={{meta.limit}}&skip={{meta.skip - meta.limit}}">Previous</a></li>
{% endif %}

{% if meta.count.total %}
{% for page in range((meta.count.total // meta.limit) + 1) %}
{% set skipper = (page) * meta.limit %}
{% if skipper == meta.skip %}
<li class="page-item"><a class="page-link active" href="?limit={{meta.limit}}&skip={{skipper}}">{{ page + 1 }}</a></li>
{% else %}
<li class="page-item"><a class="page-link" href="?limit={{meta.limit}}&skip={{skipper}}">{{ page + 1 }}</a></li>
{% endif%}
{% endfor %}

{% if not meta.skip >= meta.count.total - meta.limit %}
<li class="page-item"><a class="page-link" href="?limit={{meta.limit}}&skip={{meta.skip + meta.limit}}">Next</a></li>
{% endif %}
{% endif %}
</ul>
</nav>
</div>
3 changes: 1 addition & 2 deletions main.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,7 @@
# Use a nice format for the log messages
formatter = logging.Formatter(
"%(asctime)s [%(levelname)s] %(message)s"
)

)
console_handler.setFormatter(formatter)

uvicorn_access_logger = logging.getLogger("uvicorn.access")
Expand Down

0 comments on commit 7a6443e

Please sign in to comment.