Files
Python-for-Geeks/Chapter10/casestudy/webapp/templates/main.html
T
2021-06-30 12:36:33 +04:00

77 lines
3.2 KiB
HTML

{% extends 'base.html' %}
{% block title %} Home{% endblock title %}
{% block body %}
<div class="container my-3">
<h2>Add a Student</h2>
<form action="/" method="POST">
<div class="mb-2">
<label for="fname" class="form-label">First name</label>
<input type="text" class="form-control" name="fname" id="fname" aria-describedby="emailHelp">
</div>
<div class="mb-2">
<label for="lname" class="form-label">Last Name</label>
<input type="text" class="form-control" name="lname" id="lname" aria-describedby="emailHelp">
</div>
<div class="mb-2">
<label for="grade" class="form-label">Grade</label>
<input type="text" class="form-control" name="grade" id="grade">
</div>
<button type="submit" class="btn btn-dark">Submit</button>
</form>
</div>
<div class="container my-3">
<h2>Students</h2>
{% if students|length == 0 %}
<div class="alert alert-dark" role="alert">
No student found. Add your first student now!
</div>
{% else %}
<table class="table">
<thead>
<tr>
<th scope="col">No</th>
<th scope="col">Name</th>
<th scope="col">Grade</th>
<th scope="col">Actions</th>
</tr>
</thead>
<tbody>
{% for student in students %}
<tr>
<th scope="row">{{loop.index}}</th>
<td>{{student.name}}</td>
<td>{{student.grade}}</td>
<td>
<a href="/update/{{student.id}}" type="button" class="btn btn-outline-dark btn-sm mx-1">Update</button>
<a href="/delete/{{student.id}}" type="button" class="btn btn-outline-dark btn-sm mx-1">Delete</button>
</td>
</tr>
{% endfor %}
</tbody>
</table>
{% endif %}
</div>
<!-- Optional JavaScript; choose one of the two! -->
<!-- Option 1: Bootstrap Bundle with Popper -->
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.0.0-beta2/dist/js/bootstrap.bundle.min.js"
integrity="sha384-b5kHyXgcpbZJO/tY9Ul7kGkf1S0CWuKcCD38l8YkeH8z8QjE0GmW1gYU5S9FOnJ0"
crossorigin="anonymous"></script>
<!-- Option 2: Separate Popper and Bootstrap JS -->
<!--
<script src="https://cdn.jsdelivr.net/npm/@popperjs/core@2.6.0/dist/umd/popper.min.js" integrity="sha384-KsvD1yqQ1/1+IA7gi3P0tyJcT3vR+NdBTt13hSJ2lnve8agRGXTTyNaBYmCR/Nwi" crossorigin="anonymous"></script>
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.0.0-beta2/dist/js/bootstrap.min.js" integrity="sha384-nsg8ua9HAw1y0W1btsyWgBklPnCUAFLuTMS2G72MMONqmOymq585AcH49TLBQObG" crossorigin="anonymous"></script>
-->
{% endblock body %}