Last active
December 22, 2020 08:46
-
-
Save ahmedelgabri/8122545 to your computer and use it in GitHub Desktop.
Revisions
-
ahmedelgabri revised this gist
Dec 26, 2013 . 2 changed files with 3 additions and 3 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -5,7 +5,7 @@ A Modified function of Paul Irish's [StaticServer shell function](https://github ### How it works ```shell $ staticServer <lang> <port> #port is optional, default is 8000 ``` Here is an example of how to use it This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -4,9 +4,9 @@ staticServer() { open "http://localhost:${port}/" if [[ "$1" == "ruby" ]]; then ruby -run -ehttpd . -p$port elif [[ "$1" == "php" ]]; then php -S localhost:$port else # Set the default Content-Type to `text/plain` instead of `application/octet-stream` # And serve everything as UTF-8 (although not technically correct, this doesn’t break anything for binary files) -
ahmedelgabri revised this gist
Dec 25, 2013 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,6 +1,6 @@ ## Static server shell function A Modified function of Paul Irish's [StaticServer shell function](https://github.com/paulirish/dotfiles/blob/master/.functions#L25-L32), according to [this gist](https://gist.github.com/willurd/5720255) You can run static servers for many languages. ### How it works -
ahmedelgabri created this gist
Dec 25, 2013 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,16 @@ ## Static server shell function A Modified function of Paul Irish's [StaticServer shell function](https://github.com/paulirish/dotfiles/blob/master/.functions#L25-L32) according to [this gist](https://gist.github.com/willurd/5720255) You can run static servers for many languages. ### How it works ```shell $ staticServer <lang> <port> ``` Here is an example of how to use it ```shell $ staticServer ruby 9000 ``` I'm a shell newbie so I'm sure this can be done in a better way, so fork it, modify it & make it better. This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,15 @@ # Start an HTTP server from a directory, optionally specifying the port staticServer() { local port="${2:-8000}" open "http://localhost:${port}/" if [[ "$1" == "ruby" ]]; then ruby -run -ehttpd . -p$2 elif [[ "$1" == "php" ]]; then php -S localhost:$2 else # Set the default Content-Type to `text/plain` instead of `application/octet-stream` # And serve everything as UTF-8 (although not technically correct, this doesn’t break anything for binary files) python -c $'import SimpleHTTPServer;\nmap = SimpleHTTPServer.SimpleHTTPRequestHandler.extensions_map;\nmap[""] = "text/plain";\nfor key, value in map.items():\n\tmap[key] = value + ";charset=UTF-8";\nSimpleHTTPServer.test();' "$port" fi }