|
@@ -5,6 +5,7 @@ us = {};
|
|
|
// 引入Express模块
|
|
|
const express = require('express');
|
|
|
const path = require('path');
|
|
|
+us.http = require("http"); //引用http server服务
|
|
|
// 创建Express应用
|
|
|
const app = express();
|
|
|
|
|
@@ -12,9 +13,9 @@ const app = express();
|
|
|
app.use(express.static(path.join(__dirname, '/')));
|
|
|
|
|
|
|
|
|
-
|
|
|
-// 定义路由
|
|
|
-app.all('/', (req, res) => {
|
|
|
+us.server = us.http.createServer(function (req, res) {
|
|
|
+ // 定义路由
|
|
|
+ // app.all('/', (req, res) => {
|
|
|
//设置跨域
|
|
|
res.writeHead(200, {
|
|
|
"Content-Type": "application/json",
|
|
@@ -36,4 +37,12 @@ app.listen(3000, () => {
|
|
|
console.log('Server is running on port 3000');
|
|
|
});
|
|
|
|
|
|
+/**
|
|
|
+* 监听1473端口的处理
|
|
|
+*
|
|
|
+**/
|
|
|
+us.server.listen('1473', '', function () {
|
|
|
+ //在控制台输出监听提示
|
|
|
+ console.log("开始监听" + us.server.address().port + "......");
|
|
|
+});
|
|
|
|