Skip to content

Commit

Permalink
Push
Browse files Browse the repository at this point in the history
  • Loading branch information
BlaNKtext committed Aug 19, 2021
1 parent 3f13289 commit c7381a4
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions public/api/api.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
const http = require('http');
const url = require('url');

const hostname = '127.0.0.1';
const postport = 3000;
const getport = 3001;

var a = [];

const postserver = http.createServer((req, res) => {
var q = url.parse(req.url, true).query;
var ip = req.headers["x-real-ip"];
Expand All @@ -14,7 +17,8 @@ const postserver = http.createServer((req, res) => {
ip[3] = "**";
}
ip = ip.join(".");
} else {
}
else {
ip = "";
}
q.ip = ip;
Expand All @@ -26,19 +30,19 @@ const postserver = http.createServer((req, res) => {
}
res.statusCode = 200;
res.setHeader('Content-Type', 'text/plain');
res.setHeader('Content-Type', 'application/json');
res.setHeader('Access-Control-Allow-Origin', '*');
res.end("");
});

const getserver = http.createServer((req, res) => {
res.statusCode = 200;
res.setHeader('Content-Type', 'application/json');
res.setHeader('Access-Control-Allow-Origin', '*');
res.end(JSON.stringify(a));
});

postserver.listen(postport, hostname, () => {
console.log(`Post server running at http://${hostname}:${postport}/`);
console.log(`Server running at http://${hostname}:${postport}/`);
});
getserver.listen(getport, hostname, () => {
console.log(`Get server running at http://${hostname}:${getport}/`);
console.log(`Server running at http://${hostname}:${getport}/`);
});

0 comments on commit c7381a4

Please sign in to comment.