-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Index.html has been added to use through a
graphical interface
- Loading branch information
Showing
5 changed files
with
102 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
body { | ||
font-family: Arial, sans-serif; | ||
background-color: #f9f9f9; | ||
display: flex; | ||
justify-content: center; | ||
align-items: center; | ||
height: 100vh; | ||
margin: 0; | ||
} | ||
.summing { | ||
background-color: #fff; | ||
padding: 20px; | ||
border-radius: 10px; | ||
box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1); | ||
} | ||
.summing h1 { | ||
text-align: center; | ||
margin-bottom: 20px; | ||
} | ||
.summing input[type="number"] { | ||
width: 100%; | ||
padding: 10px; | ||
margin: 10px 0; | ||
border: 1px solid #ccc; | ||
border-radius: 5px; | ||
box-sizing: border-box; | ||
} | ||
.summing button { | ||
width: 100%; | ||
padding: 10px; | ||
background-color: #28a745; | ||
border: none; | ||
border-radius: 5px; | ||
color: #fff; | ||
font-size: 16px; | ||
cursor: pointer; | ||
} | ||
.summing button:hover { | ||
background-color: #218838; | ||
} | ||
.summing .result { | ||
margin-top: 20px; | ||
text-align: center; | ||
font-size: 18px; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="UTF-8"> | ||
<meta name="viewport" content="width=device-width, initial-scale=1.0"> | ||
<title>Summing GUI</title> | ||
<link href="index.css" rel="stylesheet"> | ||
</head> | ||
<body> | ||
<div class="summing"> | ||
<h1>Summing</h1> | ||
<input type="number" id="num1" placeholder="Enter first number"> | ||
<input type="number" id="num2" placeholder="Enter second number"> | ||
<button onclick="calculate()">Calculate</button> | ||
<div class="result" id="result"></div> | ||
</div> | ||
<script src="index.js"></script> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
function calculate() { | ||
let num1 = document.getElementById('num1').value; | ||
let num2 = document.getElementById('num2').value; | ||
|
||
// Check if both numbers are entered | ||
if (num1 === '' || num2 === '') { | ||
document.getElementById('result').innerText = 'Please enter both numbers.'; | ||
return; | ||
} | ||
|
||
// API endpoint with query parameters | ||
let apiUrl = `/sum?a=${num1}&b=${num2}`; | ||
|
||
// Fetch API call | ||
fetch(apiUrl) | ||
.then(response => { | ||
if (!response.ok) { | ||
throw new Error(`Network response was not ok: ${response.statusText}`); | ||
} | ||
return response.text(); // Assuming the API returns a plain text string | ||
}) | ||
.then(data => { | ||
document.getElementById('result').innerText = 'Result: ' + data; | ||
}) | ||
.catch(error => { | ||
document.getElementById('result').innerText = 'Error: ' + error.message; | ||
}); | ||
} |