Page:
To view a app file
3
To view a app file
matu6968 edited this page 2024-11-21 02:12:34 +01:00
To view a app file:
HTTP request type: GET
Authorization required: No
Endpoint: /apps/files/[app_name]_[app_version].js
Output:
If it does exist:
let installcamera = {
runs: true,
name: 'Camera',
ver: 6.0,
init: async function () {
const win = tk.mbw('Camera', '380px', 'auto', true, undefined, undefined);
const cam = tk.c('video', win.main, 'embed');
cam.autoplay = true;
cam.playsInline = true;
if (navigator.mediaDevices.getUserMedia) {
navigator.mediaDevices.getUserMedia({ video: true })
.then(function (stream) {
cam.srcObject = stream;
cam.onloadedmetadata = function () {
cam.play();
};
})
.catch(function (error) {
wm.notif(`Something went wrong. Make sure that WebDesk has camera permissions.`, 'Click "Open" to view error details"', () => wm.notif('Camera error details', error));
});
}
async function save() {
let canvas = document.createElement('canvas');
canvas.width = cam.videoWidth;
canvas.height = cam.videoHeight;
var context = canvas.getContext('2d');
context.drawImage(cam, 0, 0, canvas.width, canvas.height);
const silly = canvas.toDataURL('image/png');
const num = gen(7);
const bruh = `Capture ${num}.png`;
const wowzers = `/user/files/${bruh}`;
await fs.write(wowzers, silly);
wm.notif('Saved picture!', `Path: ${wowzers}`, () => app.imgview.init(silly));
}
function nocam() {
var tracks = cam.srcObject.getTracks();
tracks.forEach(function (track) {
track.stop();
});
cam.srcObject = null;
}
win.closebtn.addEventListener('mousedown', function () {
nocam();
});
tk.cb('b1', 'Capture', function () {
save();
}, win.main);
}
}
app['734017834573'] = installcamera;
installcamera = undefined;
Status code: 200
Otherwaise if it does not exist:
Status code: 404
If using a HTTP request other then GET
:
{
"error": "Method not allowed. Only GET is supported for this endpoint."
}
Status code: 405