LoginSignup
24
26

More than 5 years have passed since last update.

ワンライナーWebサーバをまとめた

Last updated at Posted at 2015-08-19

ワンライナーWebサーバを集めてみた

ワンライナー Web サーバを起動するとき100%毎回どう書くのか忘れるのでいつもこの記事をみていたのですが、毎回記事を探すところから始まるのでシェルスクリプトにまとめました。

使いかた

以下の Web サーバのどれかを起動するラッパースクリプトです。

  • Python 2.x SimpleHTTPServer
  • Python 3.x http.server
  • Ruby WEBrick via un
  • PHP (5.4+)

デフォルトは Python 2.x か 3.x です。環境によって変わります。

Usage

$ httpserver プログラム ポート番号

# デフォルト (Python 2.x or 3.x) ポート番号もデフォルトのやつ
$ httpserver

# デフォルト (Python 2.x or 3.x) ポート番号指定あり
$ httpserver 8080

# Python 2.x or 3.x
$ httpserver python 8080

# Python 3.x
$ httpserver python3 8080

# Ruby
$ httpserver ruby 8080

# PHP
$ httpserver php 8080

インストール

適当なところにリポジトリをクローンするかスクリプトファイルをダウンロードしてパスを通してください。

インストール例

$ cd ~
$ git clone git@github.com:5t111111/http-server-one-liner.git
$ export PATH=$HOME/http-server-one-liner:$PATH
$ rehash # オプション
24
26
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
24
26