Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- const http = require("http");
- const qs = require('querystring');
- const host = '0.0.0.0';
- const port = 8000;
- const requestListener = function (req, res) {
- if (req.method == 'POST') {
- let body = '';
- req.on('data', function (data) {
- body += data;
- if (body.length > 1e6) {
- req.connection.destroy();
- }
- });
- req.on('end', function () {
- let postData = qs.parse(body);
- // use POST
- console.log(new Date(), postData);
- });
- }
- res.writeHead(200);
- res.end("OK");
- };
- const server = http.createServer(requestListener);
- server.listen(port, host, () => {
- console.log(`Server is running on http://${host}:${port}`);
- });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement