node.js 目录
As I mentioned in Serve a Directory with Python, sometimes you need a directory to be "served" instead of loading the file://
location within your browser. In the past I would mess around with MAMPStack and swapping out httpdocs
directories, but there are better tools these days.
正如我在《 使用Python服务目录》中提到的那样,有时您需要“提供服务”目录,而不是在浏览器中加载file://
位置。 过去,我会搞乱MAMPStack并换出httpdocs
目录,但是现在有更好的工具了。
If you prefer to use Node.js instead of Python, you can use the http-server package:
如果您更喜欢使用Node.js而不是Python,则可以使用http-server软件包:
# Install via shell
npm install http-server -g
# Serve a directory
http-server
# Serve a directory at a specified port
http-server -p 2020
Check out the http-server NPM page to check out specific options, but I wanted to highlight how easy it can be to serve a directory with Node.js. And for JavaScript lovers like me...Node.js is the way to go.
检出http-server NPM页面以检出特定选项,但我想强调一下使用Node.js为目录提供服务有多么容易。 对于像我这样JavaScript爱好者来说,Node.js是必经之路。
node.js 目录