Skip to content

Instantly share code, notes, and snippets.

@nivertech
Forked from willurd/web-servers.md
Created June 6, 2013 11:49
Show Gist options
  • Save nivertech/5720960 to your computer and use it in GitHub Desktop.
Save nivertech/5720960 to your computer and use it in GitHub Desktop.

Revisions

  1. @willurd willurd revised this gist Jun 6, 2013. 1 changed file with 3 additions and 3 deletions.
    6 changes: 3 additions & 3 deletions web-servers.md
    Original file line number Diff line number Diff line change
    @@ -1,18 +1,18 @@
    Each of these commands will run an ad hoc http server in your current directory. Use this power wisely.

    **python 2.x**
    **Python 2.x**

    ```shell
    $ python -m SimpleHTTPServer 8000
    ```

    **python 3.x**
    **Python 3.x**

    ```shell
    $ python -m http.server 8000
    ```

    **ruby**
    **Ruby**

    Credit: http://barkingiguana.com/2010/04/11/a-one-line-web-server-in-ruby/

  2. @willurd willurd revised this gist Jun 6, 2013. 1 changed file with 3 additions and 1 deletion.
    4 changes: 3 additions & 1 deletion web-servers.md
    Original file line number Diff line number Diff line change
    @@ -29,13 +29,15 @@ $ perl -MCPAN -e "install HTTP::Server::Brick" # install dependency
    $ perl -MHTTP::Server::Brick -e '$s=HTTP::Server::Brick->new(port=>8000); $s->mount("/"=>{path=>"."}); $s->start'
    ```

    **Node.js**
    **Node.js #1**

    ```shell
    $ npm install -g http-server # install dependency
    $ http-server -p 8000
    ```

    **Node.js #2**

    ```shell
    # Runs in Node.js using node-static. No directory listings.
    $ npm install -g node-static # install dependency
  3. @willurd willurd revised this gist Jun 6, 2013. 1 changed file with 15 additions and 7 deletions.
    22 changes: 15 additions & 7 deletions web-servers.md
    Original file line number Diff line number Diff line change
    @@ -6,30 +6,38 @@ Each of these commands will run an ad hoc http server in your current directory.
    $ python -m SimpleHTTPServer 8000
    ```

    **python 3.x**

    ```shell
    # python 3.x
    $ python -m http.server 8000
    ```

    **ruby**

    Credit: http://barkingiguana.com/2010/04/11/a-one-line-web-server-in-ruby/

    ```shell
    # http://barkingiguana.com/2010/04/11/a-one-line-web-server-in-ruby/
    $ ruby -rwebrick -e'WEBrick::HTTPServer.new(:Port => 8000, :DocumentRoot => Dir.pwd).start'
    ```

    **Perl**

    Credit: http://www.perlmonks.org/?node_id=865239

    ```shell
    # http://www.perlmonks.org/?node_id=865239
    $ perl -MCPAN -e "install HTTP::Server::Brick" # install dependencies
    $ perl -MCPAN -e "install HTTP::Server::Brick" # install dependency
    $ perl -MHTTP::Server::Brick -e '$s=HTTP::Server::Brick->new(port=>8000); $s->mount("/"=>{path=>"."}); $s->start'
    ```

    **Node.js**

    ```shell
    # Runs in Node.js using http-server.
    $ npm install -g http-server # install dependencies
    $ npm install -g http-server # install dependency
    $ http-server -p 8000
    ```

    ```shell
    # Runs in Node.js using node-static. No directory listings.
    $ npm install -g node-static # install dependencies
    $ npm install -g node-static # install dependency
    $ static -p 8000
    ```
  4. @willurd willurd revised this gist Jun 6, 2013. 1 changed file with 2 additions and 1 deletion.
    3 changes: 2 additions & 1 deletion web-servers.md
    Original file line number Diff line number Diff line change
    @@ -1,7 +1,8 @@
    Each of these commands will run an ad hoc http server in your current directory. Use this power wisely.

    **python 2.x**

    ```shell
    # python 2.x
    $ python -m SimpleHTTPServer 8000
    ```

  5. @willurd willurd revised this gist Jun 6, 2013. 1 changed file with 3 additions and 3 deletions.
    6 changes: 3 additions & 3 deletions web-servers.md
    Original file line number Diff line number Diff line change
    @@ -17,18 +17,18 @@ $ ruby -rwebrick -e'WEBrick::HTTPServer.new(:Port => 8000, :DocumentRoot => Dir.

    ```shell
    # http://www.perlmonks.org/?node_id=865239
    $ perl -MCPAN -e "install HTTP::Server::Brick"
    $ perl -MCPAN -e "install HTTP::Server::Brick" # install dependencies
    $ perl -MHTTP::Server::Brick -e '$s=HTTP::Server::Brick->new(port=>8000); $s->mount("/"=>{path=>"."}); $s->start'
    ```

    ```shell
    # Runs in Node.js using http-server.
    $ npm install -g http-server
    $ npm install -g http-server # install dependencies
    $ http-server -p 8000
    ```

    ```shell
    # Runs in Node.js using node-static. No directory listings.
    $ npm install -g node-static
    $ npm install -g node-static # install dependencies
    $ static -p 8000
    ```
  6. @willurd willurd revised this gist Jun 6, 2013. 1 changed file with 1 addition and 0 deletions.
    1 change: 1 addition & 0 deletions web-servers.md
    Original file line number Diff line number Diff line change
    @@ -17,6 +17,7 @@ $ ruby -rwebrick -e'WEBrick::HTTPServer.new(:Port => 8000, :DocumentRoot => Dir.

    ```shell
    # http://www.perlmonks.org/?node_id=865239
    $ perl -MCPAN -e "install HTTP::Server::Brick"
    $ perl -MHTTP::Server::Brick -e '$s=HTTP::Server::Brick->new(port=>8000); $s->mount("/"=>{path=>"."}); $s->start'
    ```

  7. @willurd willurd revised this gist Jun 6, 2013. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion web-servers.md
    Original file line number Diff line number Diff line change
    @@ -1,4 +1,4 @@
    Change `8000` to whatever port you want.
    Each of these commands will run an ad hoc http server in your current directory. Use this power wisely.

    ```shell
    # python 2.x
  8. @willurd willurd renamed this gist Jun 6, 2013. 1 changed file with 0 additions and 0 deletions.
    File renamed without changes.
  9. @willurd willurd created this gist Jun 6, 2013.
    33 changes: 33 additions & 0 deletions servers.md
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,33 @@
    Change `8000` to whatever port you want.

    ```shell
    # python 2.x
    $ python -m SimpleHTTPServer 8000
    ```

    ```shell
    # python 3.x
    $ python -m http.server 8000
    ```

    ```shell
    # http://barkingiguana.com/2010/04/11/a-one-line-web-server-in-ruby/
    $ ruby -rwebrick -e'WEBrick::HTTPServer.new(:Port => 8000, :DocumentRoot => Dir.pwd).start'
    ```

    ```shell
    # http://www.perlmonks.org/?node_id=865239
    $ perl -MHTTP::Server::Brick -e '$s=HTTP::Server::Brick->new(port=>8000); $s->mount("/"=>{path=>"."}); $s->start'
    ```

    ```shell
    # Runs in Node.js using http-server.
    $ npm install -g http-server
    $ http-server -p 8000
    ```

    ```shell
    # Runs in Node.js using node-static. No directory listings.
    $ npm install -g node-static
    $ static -p 8000
    ```