website/projects/fishbowl.html

106 lines
2.1 KiB
HTML
Raw Normal View History

2024-09-05 02:36:11 -05:00
<!DOCTYPE html><html><head><style>
@font-face {
font-family: 'merriweather';
src: url(/res/merriweather-regular.woff2);
}
@font-face {
font-family: 'cascadia';
src: url(/res/cascadiacode.woff2);
}
body {
font-family: merriweather;
background-image: url("/res/grey.png");
background-repeat: repeat;
padding: 20px 10px 20px;
line-height: 1.75em;
height: 100%;
max-width: 40em;
display: flex;
margin: auto;
}
main {
border-radius: 15px;
padding: 15px;
background-color: #ffeedd;
margin: 2px;
width: 100%
}
code {
font-family: cascadia;
}
table {
margin-left: auto;
margin-right: auto;
}
table, th, td {
padding: 5px;
border: 3px solid black;
border-style: solid;
border-collapse: collapse;
/* text-align: center; */
align-content: center;
}
a {
color: #df3e23;
font-style: italic;
text-decoration: none;
}
a:visited {
color: #df3e23;
font-style: italic;
text-decoration: none;
}
a:hover:before {
content: "[";
font-style: normal;
color: black;
}
a:hover:after {
content: "]";
font-style: normal;
color: black;
}
</style>
</head><body><main><h1>fishbowl</h1>
<p>Choose an image and click submit. The image will be sent and processed by my
server, so be mindful of what you submit. No logs or copies of the input are
preserved.</p>
<form id="fishForm">
<label for="fishFile"> Select an image: </label>
<br/>
<input id="fishFile" accept="image/*" type="file"/>
<br/>
<input value="Run Fishbowl" type="submit"/>
</form>
<img id="fishImage" width="480" height="480"/>
&lt;script>
const form = document.getElementById("fishForm");
const image = document.getElementById("fishImage");
form.onsubmit = async (ev) => {
ev.preventDefault();
image.src = "";
try {
const file = document.getElementById("fishFile").files[0];
const arrayBuf = await file.arrayBuffer();
const response = await fetch("/api/fishbowl", {
method: 'POST',
body: arrayBuf,
});
const blob = await response.blob();
image.src = URL.createObjectURL(blob);
} catch (error) {
console.log(error);
}
}
&lt;/script>
</main></body></html>