更新 'app.js'
This commit is contained in:
parent
92e4ccf4d6
commit
bd0e90ddb8
@ -1,26 +1,26 @@
|
||||
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);
|
||||
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);
|
||||
})
|
||||
Loading…
x
Reference in New Issue
Block a user