Public
Edited
May 3, 2023
1 fork
2 stars
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
import { flowQueue } from "@tomlarkworthy/flow-queue"
Insert cell
Insert cell
Insert cell
fetch('https://untitled-16q76xhitpqk.runkit.sh/'
+ 'webcode.run/observablehq.com/@dleeftink/observable-puppeteer;webc/check/https://ipwho.is'
//+ 'api.stackexchange.com/2.3/search?site=stackoverflow&intitle=node&pagesize=14'
).then(d=>d.json())
Insert cell
fetch("https://sub.reflow.workers.dev/https://100a-34-86-81-208.ngrok.io/webcode.run/observablehq.com/@dleeftink/observable-puppeteer;webc/sink").then(d=>d.json())
Insert cell
fetch('https://init.cyclic.app/https://webcode.run/observablehq.com/@dleeftink/observable-puppeteer;webc/sink?hello='+Date.now()).then(d=>d.json())
Insert cell
mutable latest = ''
Insert cell
latest.req.headers
Insert cell
webcInit = { endpoint(
"webc",
handleWithExpress(app)
/* async (req, res,ctx) => {
// let ip = await fetch('https://ipwho.is').then(d=>d.json())
res.send({answer:req.ip});
}*/
, {
modifiers: ['terminal']
}
); return true
}
Insert cell
webserver = {
endpoint(
"webserver",
async (req, res, ctx) => {
try {
mutable weblog = mutable weblog.concat(
{t:Date.now(),req,res}
);
// Forward to a flowQueue for (async) processing
const response = await viewof webRequest.send({
req,
res,
ctx
});
res.send(response);
} catch (err) {
res.status(err.code || 500).send(err.message);
}
},
{
// livecode: "public",
}
)
}
Insert cell
mutable weblog = []
Insert cell
viewof webRequest = flowQueue({
timeout_ms: 1000
})
Insert cell
step1 = {
const data = {t:Date.now()}
viewof webRequest.resolve(webRequest.res.status(404).send(data));
//webRequest.res.status(404).send(data)
return data;
}
Insert cell

Purpose-built for displays of data

Observable is your go-to platform for exploring data and creating expressive data visualizations. Use reactive JavaScript notebooks for prototyping and a collaborative canvas for visual data exploration and dashboard creation.
Learn more