---
title: Return small HTML page
description: Deliver an HTML page from an HTML string directly inside the Worker script.
image: https://developers.cloudflare.com/dev-products-preview.png
---

> Documentation Index  
> Fetch the complete documentation index at: https://developers.cloudflare.com/workers/llms.txt  
> Use this file to discover all available pages before exploring further.

[Skip to content](#%5Ftop) 

### Tags

[ JavaScript ](https://developers.cloudflare.com/search/?tags=JavaScript)[ TypeScript ](https://developers.cloudflare.com/search/?tags=TypeScript)[ Python ](https://developers.cloudflare.com/search/?tags=Python)[ Rust ](https://developers.cloudflare.com/search/?tags=Rust) 

# Return small HTML page

**Last reviewed:**  over 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.

[![Deploy to Cloudflare](https://deploy.workers.cloudflare.com/button)](https://deploy.workers.cloudflare.com/?url=https://github.com/cloudflare/docs-examples/tree/main/workers/return-html)

This creates a repository in your GitHub account and deploys the application to Cloudflare Workers.

* [  JavaScript ](#tab-panel-9359)
* [  TypeScript ](#tab-panel-9360)
* [  Python ](#tab-panel-9361)
* [  Rust ](#tab-panel-9362)
* [  Hono ](#tab-panel-9363)

JavaScript

```

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",

      },

    });

  },

};


```

[Run Worker in Playground](https://workers.cloudflare.com/playground#LYVwNgLglgDghgJwgegGYHsHALQBM4RwDcABAEbogB2+CAngLzbPYZb6HbW5QDGU2AAwAOAMwAmAGxSA7AFZBM8QC4WLNsA5wuNPgJETpk+YvEBYAFABhdFQgBTO9gAiUAM4x0bqNFvKSGngExCRUcMD2DABEUDT2AB4AdABWblGkqFBgjuGRMXFJqVGWNnaOENgAKnQw9v5wMDBgfARQtsjJcABucG68CLAQANTA6Ljg9paWCZ5IJLj2qHDgECQA3hYkJL10VLwB9hC8ABYAFAj2AI4g9m4QAJTrm1skvLZ3JMcQwGAkDCQAAwAPABCZwAeSslQAmgAFACin2+YAAfM8tkCKLg6GiXi8gccAIwogAS9jAYHQJAA6pgwLggcgibi8SQgTAUZVju4SMBEABrEAwEgAd16JAA5o57AgCPZcOQ6NsSFZKSBcKgwIh7DTMPyZYlGRz0WzkFicQCiBYTRcICAEFRQvYRSQAEq3TxUNz2U5fH4AGierM+9jgCwQbn8G2DWyibzKTggNXsUX8UQc8RQfrARBOiG9EAYAFVKgAxbDCKL+k1bAC+1bxtfuVrr1drREsamYGi0Oh4-CEYiksgUShKtgcTlcHi8PjaVH8gS0pDCEWiEUIWnSASyOTXUTIlLIxWsE-KVWT9UazV4rXaqVsUwsayifNiAH1RuNsqn8gtCmktadl2PbBH2eiDoYI6mMwlhAA)

TypeScript

```

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;


```

Python

```

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)

}


```

TypeScript

```

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;


```

```json
{"@context":"https://schema.org","@type":"BreadcrumbList","itemListElement":[{"@type":"ListItem","position":1,"item":{"@id":"/directory/","name":"Directory"}},{"@type":"ListItem","position":2,"item":{"@id":"/workers/","name":"Workers"}},{"@type":"ListItem","position":3,"item":{"@id":"/workers/examples/","name":"Examples"}},{"@type":"ListItem","position":4,"item":{"@id":"/workers/examples/return-html/","name":"Return small HTML page"}}]}
```
