使node.js在代码上运行
我正在编码上编码,并希望运行可在localhost上运行的nodejs文件。我在codetasty上使用沙箱,因此链接类似于https://'s.codetasty'/My username/mysandbox/project/
。
var app = express();
var serv = require('http').Server(app);
app.get('/',function(req, res) {
res.sendFile(__dirname + '/client/index.html');
});
app.use('/client',express.static(__dirname + '/client'));
serv.listen(2000);
console.log("Server started.");
[当我定向到我的index.html文件https://'s.codetasty'/My username/mysandbox/project/client/index.html
时,只有hmtl“运行”,但没有nodejs在运行(在本地主机上,您只需在控制台中执行节点'filename'.js)
节点(和其他服务器端项目)在沙盒工作区上不起作用。沙盒工作区仅用于前端编码。