Skip to content

Commit a7d0d1e

Browse files
committed
working on a node.js system to save frames of animation
1 parent 2845525 commit a7d0d1e

File tree

513 files changed

+186756
-9
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

513 files changed

+186756
-9
lines changed

CT-Icon-Multi.png

15.9 KB
Loading

data.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
const fs = require('fs');
1+
import fs from 'fs';
22

33
const data = JSON.parse(fs.readFileSync('./data.json', 'utf8'));
44

index.js

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
import express from 'express';
2+
import bodyParser from 'body-parser';
3+
import fs from 'fs';
4+
5+
const app = express();
6+
app.use(bodyParser.json({ limit: '50mb' }));
7+
app.use(express.static('public', { directory: true }));
8+
9+
// Parse JSON bodies for this route
10+
app.use(express.json());
11+
12+
// Route to handle the POST request
13+
app.post('/upload', (request, response) => {
14+
const { image, filename } = request.body;
15+
const base64Data = image.replace(/^data:image\/\w+;base64,/, '');
16+
const buffer = Buffer.from(base64Data, 'base64');
17+
const savePath = `render/${filename}`;
18+
fs.writeFileSync(savePath, buffer);
19+
response.json({ message: 'Image saved successfully' });
20+
});
21+
22+
// Listen on port 3000
23+
app.listen(3000, () => {
24+
console.log('Server is listening on port 3000');
25+
});

logo.png

35.5 KB
Loading

node_modules/.bin/mime

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)