使用Node开启本地静态服务器
Tofloor
poster avatar
海天鹰
deepin
2019-02-16 07:44
Author
管理员身份运行:npm install http-server -g
如果报错:rollbackFailedOptional: verb npm-session,则网络不通,
需要设置镜像服务器:npm config set registry http://registry.npm.taobao.org
然后在你需要运行服务器的路径打开终端运行:http-server -p 8081
显示:
Starting up http-server, serving ./
Available on:
  http://127.0.0.1:8081
  http://192.168.2.103:8081
Hit CTRL-C to stop the server

然后在浏览器中打开,http://127.0.0.1:8081 即可。
实在比Apache设置方便太多,我主要用于网页在Chrome上跨域调试。
Reply Favorite View the author
All Replies
avatar
xfzfflm
deepin
2019-02-16 08:07
#1
  1. python -m http.server 8081
Copy the Code


Python 标准库, 不需要额外安装
Reply View the author
avatar
海天鹰
deepin
2019-02-17 02:12
#2
https://bbs.deepin.org/post/174770
Python 标准库, 不需要额外安装

666,不过好像是这个:python -m SimpleHTTPServer 8080
Reply View the author
avatar
xfzfflm
deepin
2019-02-19 08:09
#3
https://bbs.deepin.org/post/174770
666,不过好像是这个:python -m SimpleHTTPServer 8080

我用的 Python3, 你这是 Python2...
Reply View the author
avatar
海天鹰
deepin
2019-02-22 19:56
#4
https://bbs.deepin.org/post/174770
我用的 Python3, 你这是 Python2...

索得斯内~
Reply View the author