Skip to content
Permalink
Branch: master
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
58 lines (56 sloc) 1.5 KB
<html>
<head>
<script>const BINARIS_ACCOUNT_ID = '<account id>'</script>
<style>
html {
padding: 20px;
}
div {
color: #999;
font-family: sans-serif;
font-size: 20px;
margin-bottom: 5px;
}
input {
font-family: sans-serif;
font-size: 40px;
padding: 4px 8px;
width: 100%;
}
#output {
font-family: sans-serif;
font-size: 40px;
margin-top: 20px;
width: 100%;
}
</style>
</head>
<body>
<div>Type in some text:</div>
<input type="text" id="input"/>
<pre id="output"></pre>
<script>
const invoke = async (name, input) => {
const url = `https://run.binaris.com/v2/run/${BINARIS_ACCOUNT_ID}/${name}`;
const body = JSON.stringify(input);
const headers = { 'Content-Type': 'application/json' };
const res = await fetch(url, {
method: 'POST',
body,
headers,
});
const ct = res.headers.get('Content-Type');
if (res.status !== 200 || !ct || !ct.startsWith('application/json')) {
throw new Error(`Backend error: status=${res.status} response: ${res.body}`);
}
return res.json();
};
const $input = document.getElementById('input');
const $output = document.getElementById('output');
$input.addEventListener('input', async e => {
$output.innerHTML = await invoke('public_backend', $input.value);
});
$input.focus();
</script>
</body>
</html>
You can’t perform that action at this time.