Skip to content

Instantly share code, notes, and snippets.

@pamo
Created April 24, 2016 22:55
Show Gist options
  • Save pamo/3fa72c8c61d5baa732c672253790bd67 to your computer and use it in GitHub Desktop.
Save pamo/3fa72c8c61d5baa732c672253790bd67 to your computer and use it in GitHub Desktop.
bash server function
server ()
{
local port="${1:-8000}";
sleep 1 && open "http://localhost:${port}/" & python -c 'import SimpleHTTPServer;
map = SimpleHTTPServer.SimpleHTTPRequestHandler.extensions_map;
map[""] = "text/plain";
for key, value in map.items():
map[key] = value + ";charset=UTF-8";
SimpleHTTPServer.test();' "$port"
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment