Edit on val.town ↗

Basic examples

HTTP triggers create a URL on the public internet, like example.val.run. Copy a URL by opening a file with an HTTP trigger and clicking the copy button, or by opening the menu for that file in the file tree.

By default, URLs will be a long mess of characters, but you can easily add custom subdomains.

The simplest endpoint returns a simple JSON message:

Or return HTML with the corresponding Content-Type header:

You can also use JSX, like React:

See more examples of returning HTML and JSX.

You can also get the body of POST requests:

This echoes request headers back in the response:

We can get and return the request URL's query parameters:

Last updated