router.js 778 B

12345678910111213141516171819202122232425
  1. const express = require('express');
  2. const cors = require ('cors')
  3. const app = express();
  4. app.use(cors());
  5. app.use(express.json());
  6. app.use(express.urlencoded({ extended: true }));
  7. app.get('/', function (req, res) {
  8. var real_ip = req.get("X-Real-IP") || req.get("X-Forwarded-For") || req.ip;
  9. console.log("get,host:%s, ip:%s,date:%s",req.hostname,real_ip,new Date());
  10. res.send('Hello World');
  11. })
  12. app.post('/', function (req, res) {
  13. var real_ip = req.get("X-Real-IP") || req.get("X-Forwarded-For") || req.ip;
  14. console.log("post,host:%s, ip:%s,date:%s",req.hostname,real_ip,new Date());
  15. res.send('Hello World');
  16. })
  17. app.use('/', require("./get_role_info"));
  18. app.use('/', require("./get_server_info"));
  19. app.use('/', require("./get_server_list"));
  20. exports.app = app;