forked from givanz/VvvebJs
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsave.js
More file actions
32 lines (25 loc) · 644 Bytes
/
save.js
File metadata and controls
32 lines (25 loc) · 644 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
const express = require('express');
const app = express();
const bodyParser = require('body-parser');
const fs = require('fs');
//app.use(express.json({ limit: "200mb" }));
app.use(express.static("./"));
app.use(bodyParser.urlencoded({
extended: true,
limit: "200mb"
}));
app.post('/save.php', (req, res) => {
const { file, action, startTemplateUrl, html } = req.body;
let result = "File saved!";
fs.writeFileSync(file, html);
try {
fs.writeFileSync(file, html);
} catch (err) {
result = "Error saving file!";
console.error(err);
}
res.send(result);
});
app.listen(8080, () => {
console.log('Started');
});