Update public/script.js, public/index.html files

parent 2e0dd521
Pipeline #8610 failed with stage
in 17 seconds
<!DOCTYPE html> <!DOCTYPE html>
<html> <html>
<head> <head>
<meta charset="utf-8"> <title>Image Upload</title>
<meta name="generator" content="GitLab Pages"> <link rel="stylesheet" type="text/css" href="style.css">
<title>Plain HTML site using GitLab Pages</title> </head>
<link rel="stylesheet" href="style.css"> <body>
</head> <h1>Image Upload</h1>
<body> <input type="file" id="image-input">
<div class="navbar"> <button id="upload-button">Upload</button>
<a href="https://pages.gitlab.io/plain-html/">Plain HTML Example</a> <div id="result"></div>
<a href="https://gitlab.com/pages/plain-html/">Repository</a>
<a href="https://gitlab.com/pages/">Other Examples</a>
</div>
<h1>Hello World!</h1> <script src="script.js"></script>
</body>
<p>
This is a simple plain-HTML website on GitLab Pages, without any fancy static site generator.
</p>
</body>
</html> </html>
document.getElementById('upload-button').addEventListener('click', async function() {
const imageInput = document.getElementById('image-input');
const file = imageInput.files[0];
if (file) {
const reader = new FileReader();
reader.onloadend = async function() {
const imageBase64 = reader.result.split(',')[1];
const response = await fetch('https://functions.yandexcloud.net/d4e48qrvft4m7jei77hr', {
method: 'POST',
headers: {
'Content-Type': 'application/json'
},
body: JSON.stringify({
image_file: file.name,
image_data: imageBase64,
image_invert: true // Change this value as needed
})
});
const result = await response.json();
document.getElementById('result').textContent = JSON.stringify(result, null, 2);
};
reader.readAsDataURL(file);
}
});
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment