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

One platform to build and deploy the best data apps

Experiment and prototype by building visualizations in live JavaScript notebooks. Collaborate with your team and decide which concepts to build out.
Use Observable Framework to build data apps locally. Use data loaders to build in any language or library, including Python, SQL, and R.
Seamlessly deploy to Observable. Test before you ship, use automatic deploy-on-commit, and ensure your projects are always up-to-date.
Learn more