Skip to content

Instantly share code, notes, and snippets.

@nogajun
Created December 29, 2022 10:48
Show Gist options
  • Save nogajun/5dc248a5e11cd1ef89ec4d7fee3c8b21 to your computer and use it in GitHub Desktop.
Save nogajun/5dc248a5e11cd1ef89ec4d7fee3c8b21 to your computer and use it in GitHub Desktop.
Flaskでカレンダーを表示する
@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)
{% 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