python -m SimpleHTTPServer 有没有参数可以切换 DocumentRoot

2014-04-06 15:49:17 +08:00
 yakczh
类似 python -m SimpleHTTPServer e:\www 这种
按e:\www做为DocumentRoot 做为web服务根目录
9273 次点击
所在节点    Python
6 条回复
vmebeh
2014-04-06 16:04:58 +08:00
cd /d e:\www
python -m SimpleHTTPServer
mdjhny
2014-04-06 22:34:21 +08:00
http://gist.github.com/10006674.git
里面有一行path = os.getcwd(),这里可以改一下
icylogic
2014-04-07 08:21:04 +08:00
它是把启动目录当根目录的,所以。。。cd ... && python ...
yakczh
2014-04-07 08:38:46 +08:00
找到一款nodejs写的 
npm install http-server -g
nodejs http-server .  #当前目录做根目录 
nodejs http-server e:\www #指定目录

这个对中文支持要好得多   SimpleHTTPServer 显示中文文件全是方块
baocaixiong
2014-04-07 09:55:01 +08:00
@yakczh 不会啊,我这里都是对的呀。

python -m SimpleHTTPServer 总是当前目录作为DocumentRoot
xnh
2014-04-08 17:33:43 +08:00
SimpleHTTPServer好像是默认设置的当前路径,如果你是linux的话可以先alias pythonhttp="python -m SimpleHTTPServer"
然后cd到你想设置为DocumentRoot的目录,
执行 pythonhttp 或 pythonhttp 想要的端口 就可以了

这是一个专为移动设备优化的页面(即为了让你能够在 Google 搜索结果里秒开这个页面),如果你希望参与 V2EX 社区的讨论,你可以继续到 V2EX 上打开本讨论主题的完整版本。

https://www.v2ex.com/t/107429

V2EX 是创意工作者们的社区,是一个分享自己正在做的有趣事物、交流想法,可以遇见新朋友甚至新机会的地方。

V2EX is a community of developers, designers and creative people.

© 2021 V2EX