【发布时间】:2017-01-19 10:10:46
【问题描述】:
尝试在 google VM 机器上在节点 js 中制作最简单的“hello world”快速服务器示例,但它不起作用。 我要做的不是使用 google 的 APP ENGINE,我只是尝试在 google 计算机上创建一个 NODE JS 服务器并通过 http 连接的第一步。 我为节点 js 使用了“hello world”的谷歌代码示例,并使用http://MY_VM_EXTERNAL_IP_ADDRESS:8080 在浏览器中连接 - 不走运。 我确定我错过了一些愚蠢的东西,但不确定是什么:-(。
'use strict';
const express = require('express');
const app = express();
app.get('/', (req, res) => {
res.status(200).send('Hello, world!');
});
// Start the server
const PORT = process.env.PORT || 8080;
app.listen(PORT, () => {
console.log(`App listening on port ${PORT}`);
console.log('Press Ctrl+C to quit.');
});
【问题讨论】:
标签: node.js virtual-machine gcp