Skip to content

Commit

Permalink
Update Action name
Browse files Browse the repository at this point in the history
  • Loading branch information
robbizbal committed Oct 30, 2024
1 parent e6ba49c commit 7b75604
Show file tree
Hide file tree
Showing 2 changed files with 49 additions and 9 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/docker-publish.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Docker
name: Docker build & push

# This workflow uses actions that are not certified by GitHub.
# They are provided by a third-party and are governed by
Expand Down
56 changes: 48 additions & 8 deletions src/templates/form.html
Original file line number Diff line number Diff line change
@@ -1,14 +1,54 @@
<!DOCTYPE html>
<html>
<html lang="en">
<head>
<title>Simple Form</title>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>YoYo MaskR</title>
</head>
<body>
<h1>upload text to mask</h1>
<form method="post">
<label for="name">Input:</label><br>
<input type="text" id="ipunt" name="input"><br><br>
<input type="submit" value="Submit">
<h3>Input:</h3>
<form id="inputForm">
<input type="text" id="inputData" placeholder="Enter text to anonymize" required>
<input type="submit" value="Submit">
</form>

<h3>Response:</h3>
<textarea id="responseField" rows="10" cols="50" readonly></textarea>

<script>
document.getElementById('inputForm').addEventListener('submit', function(event) {
event.preventDefault(); // Prevent the default form submission

const inputData = document.getElementById('inputData').value;

// Use a relative URL for the API endpoint
const apiEndpoint = '/api/mask'; // Relative URL

// Send a POST request to the API
fetch(apiEndpoint, {
method: 'POST',
headers: {
'Content-Type': 'application/json',
},
body: JSON.stringify({ text: inputData }), // Send the input data as JSON
})
.then(response => {
if (!response.ok) {
throw new Error('Network response was not ok');
}
return response.json(); // Parse the JSON response
})
.then(data => {
console.log('Success:', data); // Handle the success response
// Display the response in the textarea
document.getElementById('responseField').value = JSON.stringify(data, null, 2); // Format the JSON response
})
.catch((error) => {
console.error('Error:', error); // Handle any errors
// Optionally display the error in the textarea
document.getElementById('responseField').value = 'Error: ' + error.message;
});
});
</script>
</body>
</html>
</html>

0 comments on commit 7b75604

Please sign in to comment.