我是node.js的新手,为了得到下面的代码,我遵循了本教程在11:33时给出的代码。有人能解释错误发生的原因以及如何修复吗?
目前,当我尝试访问localhost:2000时,它可以工作。但是,试图访问http://localhost:2000/client/img/bob.img会导致此错误。
Cannot GET /client/img/bob.img当前目录格式也由视频在2:35指定。
教程:https://www.youtube.com/watch?v=PfSwUOBL1YQ
var express = require("express");
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/index.html"));
serv.listen(2000);发布于 2017-05-11 07:00:08
请按下面的方式修改代码。您指定了错误的目录。
app.use("/client", express.static(__dirname + "/client"));https://stackoverflow.com/questions/43908492
复制相似问题