Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- const express = require('express');
- const os = require('os');
- const fs = require('fs');
- const app = express();
- const port = 8888;
- let body = '';
- app.post('/file', (req, res) => {
- body = '';
- req.on('data', data => {
- body += data;
- });
- req.on('end', () => {
- let dataArray = body.split(os.EOL);
- let content = dataArray.slice(dataArray.indexOf('') + 1, -2).join(os.EOL);
- fs.writeFile('file.css', content, err => {
- if (err) throw err;
- console.log('File has been saved!');
- });
- });
- res.end('ok');
- })
- app.listen(port, () => console.log(`Server has been started on port ${port}!`));
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement