Skip to content

Commit 8112f8c

Browse files
committed
Codes 4 Week14
1 parent 7486189 commit 8112f8c

File tree

4 files changed

+82
-0
lines changed

4 files changed

+82
-0
lines changed

Week14/static/images/logo.png

71.7 KB
Loading

Week14/templates/error.html

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
<!DOCTYPE html>
2+
<html lang="en" data-bs-theme="dark">
3+
<head>
4+
<meta charset="UTF-8">
5+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
6+
<title>Web Application</title>
7+
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-QWTKZyjpPEjISv5WaRU9OFeRpok6YctnYmDr5pNlyT2bRjXh0JMhjY6hW+ALEwIH" crossorigin="anonymous">
8+
</head>
9+
<body>
10+
<div class="container-sm text-center">
11+
<div class="row align-items-center">
12+
<div class="col-sm-2"></div>
13+
<div class="col-sm-8">
14+
<img src="/static/images/logo.png" alt="Classroom Attendance Tracker">
15+
<div class="alert alert-danger" role="alert">{{ message }}</div>
16+
</div>
17+
<div class="col-sm-2"></div>
18+
</div>
19+
</div>
20+
<script src="https://cdn.jsdelivr.net/npm/@popperjs/core@2.11.8/dist/umd/popper.min.js" integrity="sha384-I7E8VVD/ismYTF4hNIPjVp/Zjvgyol6VFvRkX/vR+Vc4jQkC+hVqc2pM8ODewa9r" crossorigin="anonymous"></script>
21+
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/js/bootstrap.min.js" integrity="sha384-0pUGZvbkm6XF6gxjEnlmuGrJXVbNuzT9qBBavbLwCsOGabYfZo0T0to5eqruptLy" crossorigin="anonymous"></script>
22+
</body>
23+
</html>

Week14/templates/home.html

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
<!DOCTYPE html>
2+
<html lang="en" data-bs-theme="dark">
3+
<head>
4+
<meta charset="UTF-8">
5+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
6+
<title>Web Application</title>
7+
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-QWTKZyjpPEjISv5WaRU9OFeRpok6YctnYmDr5pNlyT2bRjXh0JMhjY6hW+ALEwIH" crossorigin="anonymous">
8+
</head>
9+
<body>
10+
<div class="container-sm text-center">
11+
<div class="row align-items-center">
12+
<div class="col-sm-2"></div>
13+
<div class="col-sm-8">
14+
<img src="/static/images/logo.png" alt="Classroom Attendance Tracker">
15+
<h3>Welcome to {{ name }}</h3>
16+
<form action="/attendance" method="post">
17+
<div class="form-group">
18+
<label for="student_id">Student ID</label>
19+
<input type="text" name="student_id" id="student_id" class="form-control" required>
20+
</div>
21+
<div class="form-group">
22+
<label for="attendance_code">Attendance Code</label>
23+
<input type="text" name="attendance_code" id="attendance_code" class="form-control" required>
24+
</div>
25+
<p>&nbsp;</p>
26+
<button type="submit" class="btn btn-primary">Submit</button>
27+
</form>
28+
</div>
29+
<div class="col-sm-2"></div>
30+
</div>
31+
</div>
32+
<script src="https://cdn.jsdelivr.net/npm/@popperjs/core@2.11.8/dist/umd/popper.min.js" integrity="sha384-I7E8VVD/ismYTF4hNIPjVp/Zjvgyol6VFvRkX/vR+Vc4jQkC+hVqc2pM8ODewa9r" crossorigin="anonymous"></script>
33+
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/js/bootstrap.min.js" integrity="sha384-0pUGZvbkm6XF6gxjEnlmuGrJXVbNuzT9qBBavbLwCsOGabYfZo0T0to5eqruptLy" crossorigin="anonymous"></script>
34+
</body>
35+
</html>

Week14/webapp.py

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
from flask import Flask, render_template, request
2+
3+
4+
app = Flask(__name__)
5+
6+
7+
@app.route("/")
8+
def home_page():
9+
return render_template("home.html", name="Classroom Attendance Tracker")
10+
11+
12+
@app.route("/attendance", methods=["GET", "POST"])
13+
def attendance_page():
14+
if request.method == "POST":
15+
student_id = request.form["student_id"]
16+
attendance_code = request.form["attendance_code"]
17+
print(f"Student ID: {student_id}")
18+
print(f"Attendance Code: {attendance_code}")
19+
else:
20+
return render_template("error.html", message="Invalid request method")
21+
22+
23+
if __name__ == "__main__":
24+
app.run(debug=True)

0 commit comments

Comments
 (0)