Cloudflare Docs
Workers
Edit this page on GitHub
Set theme to dark (⇧+D)

Return small HTML page

Deliver an HTML page from an HTML string directly inside the Worker script.
 Run Worker
export default {
async fetch(request) {
const html = `<!DOCTYPE html>
<body>
<h1>Hello World</h1>
<p>This markup was generated by a Cloudflare Worker.</p>
</body>`;
return new Response(html, {
headers: {
"content-type": "text/html;charset=UTF-8",
},
});
},
};
export default {
async fetch(request: Request) {
const html = `<!DOCTYPE html>
<body>
<h1>Hello World</h1>
<p>This markup was generated by a Cloudflare Worker.</p>
</body>`;
return new Response(html, {
headers: {
"content-type": "text/html;charset=UTF-8",
},
});
},
} satisfies ExportedHandler;