Created
September 29, 2022 16:01
-
-
Save marisademeglio/44ae7cbe457c46a3cddd570f213b5464 to your computer and use it in GitHub Desktop.
pipeline webservice tester
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html lang="en"> | |
<head> | |
<meta charset="UTF-8"> | |
<meta name="viewport" content="width=device-width, initial-scale=1.0"> | |
<style> | |
body { | |
display: flex; | |
flex-direction: column; | |
gap: 2em; | |
} | |
</style> | |
</head> | |
<body> | |
<h1>Pipeline WS request tester</h1> | |
<div> | |
<label for="port">Port</label> | |
<input type="text" id="port" value="49152"> | |
</div> | |
<div> | |
<button id="get-scripts">GET <code>/scripts</code></button> | |
<button id="get-jobs">GET <code>/jobs</code></button> | |
<button id="post">POST <code>/jobs</code></button> | |
</div> | |
<textarea id="res" rows="40" cols="40"></textarea> | |
<script> | |
let baseurl = () => `http://localhost:${document.querySelector('#port').value}/ws` | |
document.querySelector("#get-scripts").addEventListener('click', async e => { | |
await doFetch('/scripts', { mode: 'cors' }) | |
}); | |
document.querySelector("#get-jobs").addEventListener('click', async e => { | |
await doFetch('/jobs', { mode: 'cors' }) | |
}); | |
document.querySelector('#post').addEventListener('click', async e => { | |
let xmlStr = `<?xml version="1.0" encoding="UTF-8" standalone="no"?><jobRequest xmlns="http://www.daisy.org/ns/pipeline/data"><nicename>EPUB 3 Validator</nicename><priority>medium</priority><script href="http://localhost:8181/ws/scripts/epub3-validator"/><option name="epub">file:///Users/marisa/dev/eleventypub/build/eleventypub-demo.epub</option></jobRequest>` | |
await doFetch('/jobs', { | |
method: 'POST', | |
body: xmlStr, | |
mode: 'cors' | |
}); | |
}) | |
async function doFetch(endpoint, headers) { | |
document.querySelector("#res").value = "Fetching..." | |
let res = await fetch(`${baseurl()}${endpoint}`, headers); | |
let text = await res.text() | |
document.querySelector("#res").value = text | |
} | |
</script> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment