thinker 剛剛丟了兩個連結出來,其中一個是用簡短的 Python one-liner 實作 HTTP 傳檔的指令

$ python -c "from SimpleHTTPServer import test; test()"

它會在當前目錄下啟動一個 HTTP 伺服器,把目錄內容提供給外界存取,也就是 directory listing。這樣的語法至少在 Python 2.3 以上都是有效的,如果我們有 Python 2.4,根據該文的 comment 提示,還可以用:

$ python -m SimpleHTTPServer

達成相同的效果,因為 Python 2.4 支援新的 -m 參數,而 SimpleHTTPServer.py 的最後兩行正是:

if __name__ == '__main__':
    test()

That's why we say Python is batteries included.

Posted by yungyuc at 19:54, 0 comment, 0 trackback.
Navigate
Add a trackback
Add a comment

Your name. (required)

Your personal website. (optional)

Your email address. Will not show in page. (suggested, but optional)

Text format is "Plain Text".

Enter "YLihV"
© hover year to navigate month: powered by django