26 lines
803 B
JavaScript
26 lines
803 B
JavaScript
const express = require('express');
|
|
const { UnsupportedMediaType } = require('http-errors');
|
|
const app = express();
|
|
const port = 1234;
|
|
console.log("[Log] Server Starting up...");
|
|
app.use(express.json());
|
|
|
|
app.get("/api/IP", (req, res) => {
|
|
UserConnection = req.connection.remoteAddress
|
|
userIP = UserConnection.replace("::ffff:","");
|
|
console.log(userIP)
|
|
if(req.query.type == 'json'){
|
|
var str = {"IP":userIP, "Status":"OK"};
|
|
str_json = JSON.stringify(str);
|
|
res.send(str_json);
|
|
}else{
|
|
res.send(userIP);
|
|
}
|
|
console.log("[Log]" + UserIP + "Connecting to This Server.");
|
|
//res.send("Hello World");
|
|
res.end();
|
|
})
|
|
|
|
app.listen(port,() => {
|
|
console.log('[Log]Express server listening at http://localhost:' + port);
|
|
}) |