python -m SimpleHTTPServerでローカルWebサーバーをたてる

server.pyというファイルを作成し、以下を記述してindex.htmlと同じ階層に置く。

Serving HTTP on 0.0.0.0 port 3000

ポート番号は好きなもので。

f:id:kgmx:20140806092612p:plain

app配下で実行する。

$./server.py
zsh: permission denied: ./server.py

拒否..された時は読み取りと実行許可を変更する。もちろん777でも良い。

$ chmod 555 ./server.py
$./server.py
Serving HTTP on 0.0.0.0 port 3000 ...
127.0.0.1 - - [06/Aug/2014 07:37:45] "GET / HTTP/1.1" 200 -
127.0.0.1 - - [06/Aug/2014 07:37:45] code 404, message File not found
...............

http://localhost:3000/を見てみると、index.htmlが表示されているはず(´∇`)