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

parent 2e0dd521
Pipeline #8610 failed with stage
in 17 seconds
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="generator" content="GitLab Pages">
<title>Plain HTML site using GitLab Pages</title>
<link rel="stylesheet" href="style.css">
</head>
<body>
<div class="navbar">
<a href="https://pages.gitlab.io/plain-html/">Plain HTML Example</a>
<a href="https://gitlab.com/pages/plain-html/">Repository</a>
<a href="https://gitlab.com/pages/">Other Examples</a>
</div>
<head>
<title>Image Upload</title>
<link rel="stylesheet" type="text/css" href="style.css">
</head>
<body>
<h1>Image Upload</h1>
<input type="file" id="image-input">
<button id="upload-button">Upload</button>
<div id="result"></div>
<h1>Hello World!</h1>
<p>
This is a simple plain-HTML website on GitLab Pages, without any fancy static site generator.
</p>
</body>
<script src="script.js"></script>
</body>
</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