Skip to content

Commit

Permalink
changing the colors
Browse files Browse the repository at this point in the history
  • Loading branch information
ahmed-ellaban committed Jun 30, 2024
1 parent eb1f67e commit 1d3110e
Show file tree
Hide file tree
Showing 2 changed files with 86 additions and 14 deletions.
4 changes: 3 additions & 1 deletion app.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,9 @@ def gpa_calculator():
# 3: No changes
second_gpa /= 5
total_gpa = (first_gpa + second_gpa) / 2
return {"items": items, "total_gpa": total_gpa, "second_gpa": second_gpa, "first_gpa": first_gpa}

return {"items": items, "total_gpa": round(total_gpa, 3), "second_gpa": round(second_gpa, 3),
"first_gpa": round(first_gpa, 3)}


@app.route('/')
Expand Down
96 changes: 83 additions & 13 deletions templates/homepage.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,87 @@
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Subjects and Grades</title>
<style>
body {
font-family: Arial, sans-serif;
margin: 20px;
}

h2 {
color: #333;
font-size: 1.5em;
}

table {
width: 100%;
border-collapse: collapse;
margin-bottom: 20px;
font-size: 1em;
}

th, td {
border: 1px solid black;
border: 1px solid #ddd;
padding: 8px;
text-align: left;
}

th {
background-color: #f2f2f2;
background-color: #f4f4f4;
font-weight: bold;
}

input[type="number"], input[type="text"] {
width: 100%;
padding: 8px;
box-sizing: border-box;
border: 1px solid #ccc;
border-radius: 4px;
font-size: 1em;
}

input[type="submit"] {
background-color: #4CAF50;
color: white;
padding: 10px 20px;
border: none;
border-radius: 4px;
cursor: pointer;
font-size: 1em;
}

input[type="submit"]:hover {
background-color: #45a049;
}

.result-table {
margin-top: 20px;
}

.result-table th {
background-color: #f4f4f4;
}

.gpa-input {
width: 50%;
}

@media (max-width: 768px) {
h2 {
font-size: 1.2em;
}

th, td {
padding: 6px;
font-size: 0.9em;
}

input[type="number"], input[type="text"], .gpa-input {
font-size: 0.9em;
padding: 6px;
}

.gpa-input {
width: 100%;
}
}
</style>
<script>
Expand Down Expand Up @@ -48,22 +118,22 @@
},
body: JSON.stringify(data)
})
.then(response => response.json())
.then(data => {
console.log('Success:', data);
displayResults(data);
})
.catch((error) => {
console.error('Error:', error);
});
.then(response => response.json())
.then(data => {
console.log('Success:', data);
displayResults(data);
})
.catch((error) => {
console.error('Error:', error);
});
}

function displayResults(data) {
const resultsDiv = document.getElementById('results');
resultsDiv.innerHTML = `
<h2>Results</h2>
<p>First Semiterm GPA: ${data.first_gpa}</p>
<p>Second Semiterm GPA: ${data.second_gpa}</p>
<p>First Semi term GPA: ${data.first_gpa}</p>
<p>Second Semi term GPA: ${data.second_gpa}</p>
<p>Total GPA: ${data.total_gpa}</p>
<table class="result-table">
<thead>
Expand Down Expand Up @@ -173,7 +243,7 @@ <h2>Choose two subjects from the following three:</h2>
</tbody>
</table>

<h2>First Semiterm GPA</h2>
<h2>First Semi term GPA:</h2>
<input type="number" max="4" min="0" step="0.01" name="first_semiterm_gpa" required>

<br><br>
Expand Down

0 comments on commit 1d3110e

Please sign in to comment.