LoginSignup
0
4

More than 5 years have passed since last update.

Python: 標準モジュールで簡易的なWebサーバーを立ち上げる

Posted at

コマンドラインで下記を実行。

$ python3 -m http.server 8080

余談

リクエストを見たいだけなら、nc -lで良かったりする。

$ nc -l 8080

この状態で別のプロセスからcurl localhost:8080を実行すると、下記のような結果が得られる。

$ nc -l 8080
GET / HTTP/1.1
Host: localhost:8080
User-Agent: curl/7.54.0
Accept: */*

もちろんncはHTTPのプロトコルでお話しているわけではなく、curlのプロセスは終了しない。Ctrl+Cで切断する。

0
4
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
4