-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathindex.html
More file actions
100 lines (88 loc) · 3.22 KB
/
index.html
File metadata and controls
100 lines (88 loc) · 3.22 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Timetable Generator</title>
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.2/dist/css/bootstrap.min.css" rel="stylesheet">
<style>
body { padding: 20px; }
.result { margin-top: 30px; }
pre { background: #f8f9fa; padding: 15px; border-radius: 5px; }
</style>
</head>
<body>
<div class="container">
<h1 class="mb-4">University Timetable Generator</h1>
<form id="timetableForm" class="row g-3">
<!-- Sections -->
<div class="col-md-6">
<label class="form-label">Sections & Strength</label>
<textarea class="form-control" id="sections" rows="2"
placeholder='e.g. {"A": 70, "B": 100}'></textarea>
</div>
<!-- Classrooms -->
<div class="col-md-6">
<label class="form-label">Classrooms & Capacity</label>
<textarea class="form-control" id="classrooms" rows="2"
placeholder='e.g. {"R1": 200, "R2": 230}'></textarea>
</div>
<!-- Labs -->
<div class="col-md-6">
<label class="form-label">Labs & Capacity</label>
<textarea class="form-control" id="labs" rows="2"
placeholder='e.g. {"L1": 70, "L2": 50}'></textarea>
</div>
<!-- Subject-Teacher Mapping -->
<div class="col-md-6">
<label class="form-label">Subjects → Teacher IDs</label>
<textarea class="form-control" id="subjects" rows="2"
placeholder='e.g. {"TCS-531": "AB01", "TMA-502": "HP18"}'></textarea>
</div>
<!-- Generations -->
<div class="col-md-4">
<label class="form-label">Generations</label>
<input type="number" class="form-control" id="generations" value="20">
</div>
<!-- Submit -->
<div class="col-12">
<button type="submit" class="btn btn-primary">Generate Timetable</button>
</div>
</form>
<!-- Result -->
<div class="result">
<h3>Result</h3>
<pre id="output">Fill the form and click "Generate Timetable".</pre>
</div>
</div>
<script>
document.getElementById("timetableForm").addEventListener("submit", async function(e) {
e.preventDefault();
// collect values
const sections = JSON.parse(document.getElementById("sections").value || "{}");
const classrooms = JSON.parse(document.getElementById("classrooms").value || "{}");
const labs = JSON.parse(document.getElementById("labs").value || "{}");
const subjects = JSON.parse(document.getElementById("subjects").value || "{}");
const generations = parseInt(document.getElementById("generations").value || "20");
// build payload (minimal input)
const payload = {
sections,
classrooms,
labs,
subjects,
generations
};
try {
const res = await fetch("http://127.0.0.1:5000/generate", {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify(payload)
});
const data = await res.json();
document.getElementById("output").textContent = JSON.stringify(data, null, 2);
} catch (err) {
document.getElementById("output").textContent = "Error: " + err;
}
});
</script>
</body>
</html>