Return HTML
Return a Simple HTTP Page.
async function onRequest({ req }) {
const request = req.request;
// Only accept GET Requests
if (request.method !== "GET") return new Response("Not Allowed", {
status: 405,
headers: {
Allow: "GET"
}
});
const html = `<!DOCTYPE html>
<html>
<head>
<title>Vous Etes Perdu ?</title>
</head>
<body>
<h1>Perdu sur Swarmd ?</h1>
<h2>Pas de panique, on va vous aider</h2>
<strong>
<pre>
* <----- vous êtes ici </pre></strong>
</body>
</html>`;
// Send the response back
req.respondWith(new Response(html, {
status: 200,
headers: {
"content-type": "text/html;charset=UTF-8",
}
}))
}
export { onRequest }