Public
HTTP (deprecated)
version 115
Readme

Usage

Simple Example

To add an example, just create a val. The val should start with a JSDoc style multi line comment that describes the example:

/** * @title HTTP server: Hello World * @description An example of a HTTP server that serves a "Hello World" message. */ // this comment will be displayed on the left export const server = () => new Response("Hello world!")

The title is required.

Then, you can write the code. Code can be prefixed with a comment that describes the code. The comment will be rendered next to the code in the example page.

Make sure your val is public, then go to https://pomdtr-val_town_by_example.web.val.run/v/<your-username>/<your-val>

Using multiple vals

You can add another val to your example by adding an @include directive

/** * @title HTTP server: Hello World * @description An example of a HTTP server that serves a "Hello World" message. * @include pomdtr/secondary_val */

See @pomdtr/react_example

Adding external resources to your example

You can attach an external link to your val by using the @resource directive. External resources are specified using a markdown link.

/** * @title HTTP server: Hello World * @description An example of a HTTP server that serves a "Hello World" message. * @resource [Val Town Docs](https://docs.val.town) **/

Adding examples to the homepage

Just add your val in @pomdtr/val_town_by_example_toc

Val Town is a social website to write and deploy JavaScript.
Build APIs and schedule functions from your browser.
Comments
Nobody has commented on this val yet: be the first!
pomdtr-valtownbyexample.web.val.run
April 10, 2024