【发布时间】:2019-02-07 04:13:37
【问题描述】:
我正在尝试以快递方式在我的公共文件夹中提供登录页面,但到目前为止我一直无法这样做。我试图走这条路,但我不知道为什么它不起作用。我想要的是,我可以在回调中包含更多代码,但由于现在我可以这样做,当我尝试使回调成为一个完整的函数时,它也不起作用。
My folder structure
- root
- server
- server.js
- public
- login
- index.html
const express = require('express');
const app = express();
const path = require('path');
app.listen(4000);
console.log('server started\n');
app.get('/', () => app.use(express.static(__dirname + '/public/login')));
// what i want to have
app.get('/', () => {
// serve file
});
【问题讨论】:
-
将路径更改为 __dirname + '../public'
-
这很遗憾不起作用,没有 __dirname 它也不起作用
-
请您在提问前多搜索一下。看到所有这些帖子都与你的相似,他们很好地回答了你的问题。帖子 1:stackoverflow.com/questions/52122677,帖子 2:stackoverflow.com/questions/51967362,帖子 3:stackoverflow.com/questions/5208321,帖子 4:stackoverflow.com/questions/52014410,帖子 5:stackoverflow.com/questions/51967761
-
@NAVIN 没有任何帖子与这个问题有关?!此外,您标记的副本与此无关。在浪费大家时间之前,请仔细阅读问题
标签: javascript express