推荐学习书目
› 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 · Apr 6, 2014 · 10589 views
    This topic created in 4558 days ago, the information mentioned may be changed or developed.
    类似 python -m SimpleHTTPServer e:\www 这种
    按e:\www做为DocumentRoot 做为web服务根目录
    6 replies  •  1970-01-01 08:00:00 +08:00
    vmebeh
        1
    vmebeh  
       Apr 6, 2014
    cd /d e:\www
    python -m SimpleHTTPServer
    mdjhny
        2
    mdjhny  
       Apr 6, 2014   ❤️ 1
    http://gist.github.com/10006674.git
    里面有一行path = os.getcwd(),这里可以改一下
    icylogic
        3
    icylogic  
       Apr 7, 2014 via Android
    它是把启动目录当根目录的,所以。。。cd ... && python ...
    yakczh
        4
    yakczh  
    OP
       Apr 7, 2014
    找到一款nodejs写的 
    npm install http-server -g
    nodejs http-server .  #当前目录做根目录 
    nodejs http-server e:\www #指定目录

    这个对中文支持要好得多   SimpleHTTPServer 显示中文文件全是方块
    baocaixiong
        5
    baocaixiong  
       Apr 7, 2014
    @yakczh 不会啊,我这里都是对的呀。

    python -m SimpleHTTPServer 总是当前目录作为DocumentRoot
    xnh
        6
    xnh  
       Apr 8, 2014
    SimpleHTTPServer好像是默认设置的当前路径,如果你是linux的话可以先alias pythonhttp="python -m SimpleHTTPServer"
    然后cd到你想设置为DocumentRoot的目录,
    执行 pythonhttp 或 pythonhttp 想要的端口 就可以了
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Privacy   ·   Solana   ·   4341 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 32ms · UTC 09:59 · PVG 17:59 · LAX 02:59 · JFK 05:59
    ♥ Do have faith in what you're doing.