Skip to content

Instantly share code, notes, and snippets.

@mylamour
Last active January 12, 2017 06:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mylamour/884cdbea3e68d38fc02b71f6b2613d83 to your computer and use it in GitHub Desktop.
Save mylamour/884cdbea3e68d38fc02b71f6b2613d83 to your computer and use it in GitHub Desktop.
Different Way to Open a HTTP SERVER (temp or not )

python:

  • python2 -m SimpleHTTPServer
  • python3 -m http.server
  • twistd -n web -p 8000 --path .

ruby:

  • ruby -rwebrick -e "WEBrick::HTTPServer.new(:Port => 8888, :DocumentRoot => Dir.pwd).start"
  • ruby -run -ehttpd . -p8000

php:

  • php -S 0.0.0.0:8888

nodejs :

  • npm install http-server && http-server
  • simply use express to create a http server

bash :

  • https://github.com/liamjack/BashHTTPd
  • { echo -ne "HTTP/1.0 200 OK\r\nContent-Length: $(wc -c <some.file)\r\n\r\n"; cat some.file; } | nc -l 8080
  • { echo -ne "HTTP/1.0 200 OK\r\n\r\n"; cat some.file; } | nc -l -p 8080

Perl:

  • plackup -MPlack::App::Directory -e 'Plack::App::Directory->new(root=>".");' -p 8000

Erlang:

erl -s inets -eval 'inets:start(httpd,[{server_name,"NAME"},{document_root, "."},{server_root, "."},{port, 8000},{mime_types,[{"html","text/html"},{"htm","text/html"},{"js","text/javascript"},{"css","text/css"},{"gif","image/gif"},{"jpg","image/jpeg"},{"jpeg","image/jpeg"},{"png","image/png"}]}]).'



go :

```go
   package main
   
   import (
       "fmt"; "log"; "net/http"
   )
   
   func main() {
       fmt.Println("Serving files in the current directory on port 8080")
       http.Handle("/", http.FileServer(http.Dir(".")))
       err := http.ListenAndServe(":8080", nil)
       if err != nil {
           log.Fatal("ListenAndServe: ", err)
       }
   }

plugin:

Other:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment