Skip to content

Instantly share code, notes, and snippets.

@mewmix
Created August 13, 2023 07:07
Show Gist options
  • Save mewmix/f0d75b84441d1bbd50b90cba1b3ca4f6 to your computer and use it in GitHub Desktop.
Save mewmix/f0d75b84441d1bbd50b90cba1b3ca4f6 to your computer and use it in GitHub Desktop.
upload test
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Image Upload</title>
</head>
<body>
<h1>Upload Image</h1>
<input type="file" id="file-input">
<button id="submit-button">Submit</button>
<div id="response-container" style="display: none;">
<h2>Response from Server:</h2>
<pre id="response-data"></pre>
</div>
<script>
document.addEventListener("DOMContentLoaded", () => {
const url = "http://173.255.220.99:5000/pin";
const tezosAddress = "new_addy";
const twitterAddress = "new_twitter_address";
const fileInput = document.getElementById("file-input");
const submitButton = document.getElementById("submit-button");
const responseContainer =
document.getElementById("response-container");
const responseDataElement =
document.getElementById("response-data");
submitButton.addEventListener("click", () => {
const formData = new FormData();
formData.append("file", fileInput.files[0]);
formData.append("tezos_address", tezosAddress);
formData.append("twitter_address", twitterAddress);
fetch(url, {
method: "POST",
body: formData,
})
.then(response => response.text())
.then(data => {
responseContainer.style.display = "block";
responseDataElement.textContent = data;
})
.catch(error => {
responseContainer.style.display = "block";
responseDataElement.textContent = "Error: " + error;
});
});
});
</script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment