Public
HTTP (deprecated)
Val Town is a social website to write and deploy JavaScript.
Build APIs and schedule functions from your browser.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
import shlex from "npm:shlex";
const script = (webEndpoint) =>
`#!/bin/sh
if [ $# -eq 0 ]; then
exec sunbeam fetch ${shlex.quote(webEndpoint)}
fi
exec sunbeam -d "@-" -X POST ${shlex.quote(webEndpoint)}
`;
export default function(req: Request) {
const [, author, name] = new URL(req.url).pathname.split("/");
if (!author || !name) {
return new Response("Could not extract val author or name from request", {
status: 400,
});
}
const webEndpoint = `${author}-${name}.web.val.run`;
return new Response(script(webEndpoint), {
headers: {
"Content-Type": "text/x-shellscript",
},
});
}
pomdtr-sunbeam.web.val.run
November 27, 2023