python -mでSimpleHTTPServerを使う
python -mは標準モジュールにいろいろな機能を提供してくれて便利。
カレントディレクトリをhttpで公開
$ python -m SimpleHTTPServer Serving HTTP on 0.0.0.0 port 8000 ...
これだけで公開できる。1ページしかない時でスピード重視ならこれでいいじゃない。
同じディレクトリにindex.htmlを作っておけばちゃんと読み込まれる。
<!DOCTYPE html> <html> <head> <meta charset="utf-8" /> <title>SimpleHTTPSserver</title> </head> <body> <p>Hello World!!</p> </body> </html>
python -m を使わない場合起動するためだけにファイル作る、ひと手間が発生。
simplehttp.py
import SimpleHTTPServer
SimpleHTTPServer.test()
pythonのシェルで実行するものをそのまま書いただけ。
$ python simplehttp.py Serving HTTP on 0.0.0.0 port 8000 ...
他にもpython -mでsmtpとか簡単に立てれるなどなど。
http://answer.pythonpath.jp/questions/506/python-m