Template Gallery

These templates are simple building blocks for building a Workers script.

Hello World

Simple Hello World in JS.

Paste this into your terminal:

Hello World Rust

Simple Hello World in Rust.

Paste this into your terminal:

Router

Selects the logic based on the request method and URL. Use with REST APIs or apps that require routing logic.

Paste this into your terminal:

Static

Generates a fully functioning HTML page from raw HTML or sends raw JSON defined within your script.

Paste this into your terminal:

Fetch

Examples of making fetch requests from within your Worker script including generating JSON post requests then reading in the resulting response body.

Paste this into your terminal:

Incoming Request

Examples of reading in a POST request body of type JSON and form-data.

Paste this into your terminal:

Redirects

Examples of sending single and bulk redirects from a Worker script

Paste this into your terminal:

img-color-worker

Retrieve the dominant color of a PNG or JPEG image

Paste this into your terminal:
wrangler generate img-color https://github.com/xtuc/img-color-worker

binast-cf-worker

Serve BinAST via a Cloudflare Worker

Paste this into your terminal:
wrangler generate binast-cf-worker https://github.com/xtuc/binast-cf-worker-template