Return small HTML page
  Last reviewed:  almost 2 years ago  
  Deliver an HTML page from an HTML string directly inside the Worker script.
If you want to get started quickly, click on the button below.
This creates a repository in your GitHub account and deploys the application to Cloudflare Workers.
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): Promise<Response> {    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;from workers import WorkerEntrypoint, Response
class Default(WorkerEntrypoint):    async def fetch(self, request):        html = """<!DOCTYPE html>        <body>          <h1>Hello World</h1>          <p>This markup was generated by a Cloudflare Worker.</p>        </body>"""
        headers = {"content-type": "text/html;charset=UTF-8"}        return Response(html, headers=headers)use worker::*;
#[event(fetch)]async fn fetch(_req: Request, _env: Env, _ctx: Context) -> Result<Response> {    let html = r#"<!DOCTYPE html>    <body>      <h1>Hello World</h1>      <p>This markup was generated by a Cloudflare Worker.</p>    </body>    "#;    Response::from_html(html)}import { Hono } from "hono";import { html } from "hono/html";
const app = new Hono();
app.get("*", (c) => {  const doc = html`<!DOCTYPE html>    <body>      <h1>Hello World</h1>      <p>This markup was generated by a Cloudflare Worker with Hono.</p>    </body>`;
  return c.html(doc);});
export default app;Was this helpful?
- Resources
- API
- New to Cloudflare?
- Directory
- Sponsorships
- Open Source
- Support
- Help Center
- System Status
- Compliance
- GDPR
- Company
- cloudflare.com
- Our team
- Careers
- © 2025 Cloudflare, Inc.
- Privacy Policy
- Terms of Use
- Report Security Issues
- Trademark