V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
推荐学习书目
Learn Python the Hard Way
Python Sites
PyPI - Python Package Index
http://diveintopython.org/toc/index.html
Pocoo
值得关注的项目
PyPy
Celery
Jinja2
Read the Docs
gevent
pyenv
virtualenv
Stackless Python
Beautiful Soup
结巴中文分词
Green Unicorn
Sentry
Shovel
Pyflakes
pytest
Python 编程
pep8 Checker
Styles
PEP 8
Google Python Style Guide
Code Style from The Hitchhiker's Guide
yakczh
V2EX  ›  Python

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

  •  
  •   yakczh · 2014-04-06 15:49:17 +08:00 · 9263 次点击
    这是一个创建于 3665 天前的主题,其中的信息可能已经有所发展或是发生改变。
    类似 python -m SimpleHTTPServer e:\www 这种
    按e:\www做为DocumentRoot 做为web服务根目录
    6 条回复    1970-01-01 08:00:00 +08:00
    vmebeh
        1
    vmebeh  
       2014-04-06 16:04:58 +08:00
    cd /d e:\www
    python -m SimpleHTTPServer
    mdjhny
        2
    mdjhny  
       2014-04-06 22:34:21 +08:00   ❤️ 1
    http://gist.github.com/10006674.git
    里面有一行path = os.getcwd(),这里可以改一下
    icylogic
        3
    icylogic  
       2014-04-07 08:21:04 +08:00 via Android
    它是把启动目录当根目录的,所以。。。cd ... && python ...
    yakczh
        4
    yakczh  
    OP
       2014-04-07 08:38:46 +08:00
    找到一款nodejs写的 
    npm install http-server -g
    nodejs http-server .  #当前目录做根目录 
    nodejs http-server e:\www #指定目录

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

    python -m SimpleHTTPServer 总是当前目录作为DocumentRoot
    xnh
        6
    xnh  
       2014-04-08 17:33:43 +08:00
    SimpleHTTPServer好像是默认设置的当前路径,如果你是linux的话可以先alias pythonhttp="python -m SimpleHTTPServer"
    然后cd到你想设置为DocumentRoot的目录,
    执行 pythonhttp 或 pythonhttp 想要的端口 就可以了
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   5571 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 29ms · UTC 06:08 · PVG 14:08 · LAX 23:08 · JFK 02:08
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.