【发布时间】:2019-04-29 17:25:17
【问题描述】:
我正在使用 node 和 express js 的组合来加载我的 html 页面。我的要求是,当用户从计算机 A 在浏览器中输入 http://localhost:8080/loadPage 时,应用程序应该在计算机 B 中启动。两台计算机都属于同一个 LAN。请提出一种方法。
【问题讨论】:
我正在使用 node 和 express js 的组合来加载我的 html 页面。我的要求是,当用户从计算机 A 在浏览器中输入 http://localhost:8080/loadPage 时,应用程序应该在计算机 B 中启动。两台计算机都属于同一个 LAN。请提出一种方法。
【问题讨论】:
我想知道您使用哪种前端技术来开发您的 UI。所以,我可以提出一些建议。
例如:
方法一:
If you are developing your UI in Angular than you can use ng serve --host 192.xxx.xx.xx --port zzzz
通过这种方式,您可以运行 Angular 应用程序,也可以在另一台计算机浏览器中使用
http://192.xxx.xx.xx:zzzz
方法二:
如果在 node.js 中渲染一些前端应用程序,你可以使用
const express = require('express');
const app = express();
var port = process.env.PORT || 3000;
app.use(express.static('./folder_with_html'));
app.get('/', (req, res) => {
res.sendFile(__dirname + '/folder_with_html/index.html');
});
谢谢
【讨论】: