Created
December 29, 2022 10:48
-
-
Save nogajun/5dc248a5e11cd1ef89ec4d7fee3c8b21 to your computer and use it in GitHub Desktop.
Flaskでカレンダーを表示する
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@app.route('/calendar') | |
def month_list(): | |
dt_now = datetime.now() | |
month = calendar.monthcalendar(dt_now.year,dt_now.month) | |
return render_template("calendar.html", month = month) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{% extends "template.html" %} | |
{% block section %} | |
<table class="table table-striped table-hover"> | |
<thead> | |
<tr> | |
{% for i in ["SUN","MON","TUR","WED","THU","FRI","SAT"] %} | |
<th scope="col" class="text-center fw-bold">{{ i }}</th> | |
{% endfor %} | |
</tr> | |
</thead> | |
<tbody> | |
{% for week in month %} | |
<tr> | |
{% for day in week %} | |
{% if day %} | |
<td class="text-center">{{ day }}</td> | |
{% else %} | |
<td class="text-center"></td> | |
{% endif %} | |
{% endfor %} | |
</tr> | |
{% endfor %} | |
</tbody> | |
</table> | |
{% endblock %} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment