Public
Edited
Apr 20, 2023
Insert cell
Insert cell
Insert cell
hostname = "http://localhost:3000"
Insert cell
data = fetch(`${hostname}/rr_gcode?gcode=G0 X100 Y50`)
.then((response) => response.json())
.catch((error) => {
console.error(error);
return error;
})
Insert cell
function move(x, y) {
return () => {
return fetch(`${hostname}/rr_gcode?gcode=G0 X${x} Y${y}`)
.then((response) => response.json())
.catch((error) => {
console.error(error);
return error;
});
};
}
Insert cell
move(0, 0)
Insert cell
// TODO rather than relying on promises, add multiple things to a file to upload
Insert cell
Insert cell
payload = new Blob([testMultiple])
Insert cell
params = ({
filename: "ojs-upload-test.nc",
date: new Date().toISOString()
})
Insert cell
params.date
Insert cell
function doUpload() {
return fetch(
`${hostname}/rr_upload?name=0:/gcodes/${params.filename}&time=${params.date}`,
{
method: "POST",
headers: new Headers({ "content-type": "text/plain" }),
body: payload
}
)
.then((response) => {
return response.text();
})
.catch((err) => {
return err;
});
}
Insert cell
function doRunFile() {
return fetch(`${hostname}/rr_gcode?gcode=M32 "0:/gcodes/${params.filename}"`)
.then((response) => {
return response.text();
})
.catch((err) => {
return err;
});
}
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