express.js代码在本地计算机上运行,但不在aws-cloud9 IDE预览上运行
我是Express.js和AWS-cloud9 IDE的新手。我正在尝试在AWS-cloud9 IDE上运行以下代码。我在终端上获得了正确的输出,但是在预览浏览器上没有/错误输出。
const express = require('express');
const data = require('./data/data.json');
const app = express();
const PORT = 3000;
app.get('/', (req, res) => {
res.send(`a GET response for / on port ${PORT}.`);
});
app.listen(3000, () => {
console.log(`server started on port ${PORT}`);
//console.log(data);
});
预期输出:
a GET response for / on port 3000.
实际输出:
Cannot GET /vfs/c6f5fa76bfff441c9dbcaa02d4c81a14/previewlocalhost:3000/