Add To view a app file
parent
757b0d47ed
commit
bd94626b10
74
To-view-a-app-file.md
Normal file
74
To-view-a-app-file.md
Normal file
|
@ -0,0 +1,74 @@
|
||||||
|
# To view a app file:
|
||||||
|
|
||||||
|
## HTTP request type: `GET`
|
||||||
|
|
||||||
|
## Authorization required: No
|
||||||
|
|
||||||
|
## Endpoint: `/uploads/[app_name]/index.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:
|
||||||
|
```
|
||||||
|
404 page not found
|
||||||
|
|
||||||
|
Status code: 404
|
||||||
|
```
|
Loading…
Reference in New Issue
Block a user