【发布时间】:2020-06-19 15:36:51
【问题描述】:
我已经完成了设置图像以显示在我的应用程序中的操作:
http://www.tutorialsteacher.com/nodejs/serving-static-files-in-nodejs
我有当前目录结构:
rootproject
-public
--images
---image.jpg
server.js
server.js:
// require all dependencies
var express = require('express');
var app = express();
var PythonShell = require('python-shell');
var path = require('path');
// set up the template engine
app.set('views', './views');
app.set('view engine', 'pug');
app.use("/public", express.static(path.join(__dirname, 'public')));
index.pug:
html
head
title= title
body
img(src='/static/images/image.jpg' , alt='some image')
h1= message
但这不起作用,并在控制台中显示:GET http://localhost:3000/static/images/image.jpg 404 (Not Found)
【问题讨论】: