Send Raw HTML

Delivers an HTML page from HTML directly in the Worker script.

Copy into a Worker script:
async function handleRequest(request) { const init = { headers: { 'content-type': 'text/html;charset=UTF-8', }, } return new Response(someHTML, init) } addEventListener('fetch', event => { return event.respondWith(handleRequest(event.request)) }) const someHTML = `<!DOCTYPE html> <html> <body> <h1>Hello World</h1> <p>This is all generated using a Worker</p> <iframe width="560" height="315" src="https://www.youtube.com/embed/dQw4w9WgXcQ" frameborder="0" allow="accelerometer; autoplay; encrypted-media; gyroscope; picture-in-picture" allowfullscreen ></iframe> </body> </html> `