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
import { eval_ } from "https://esm.town/v/stevekrouse/eval_";
import { fetchTweet } from "https://esm.town/v/dpetrouk/fetchTweet?v=35";
export let xeval = async (req: Request) => {
let tweet, code, result;
try {
tweet = await fetchTweet(req.url);
code = tweet.text.split("```")[1]
.trim()
.replaceAll(/&lt;/g, "<")
.replaceAll(/&gt;/g, ">")
.replaceAll(/&amp;/g, "&");
result = await eval_(code, [req]);
return result;
}
catch (e) {
return Response.json({ code, tweet, result }, { status: 500 });
}
};
stevekrouse-xeval.web.val.run
October 23, 2023