From c1c05cb460d88c6611f18265b485e0e90c3b45c9 Mon Sep 17 00:00:00 2001 From: Mathias Bynens Date: Sat, 31 Dec 2011 15:41:21 +0100 Subject: `server` function: Set the default Content-Type to `text/plain` instead of `application/octet-stream` Hat tip to @cowboy: https://github.com/cowboy/dotfiles/blob/2874a86d207883a18e5e4c01219f9adb42d82c09/bin/serve#L26-43 --- .functions | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.functions b/.functions index 990a0cc..0caab74 100644 --- a/.functions +++ b/.functions @@ -6,7 +6,9 @@ function md() { # Start an HTTP server from a directory, optionally specifying the port function server() { local port="${1:-8000}" - open "http://localhost:${port}/" && python -m SimpleHTTPServer "$port" + open "http://localhost:${port}/" + # Set the default Content-Type to `text/plain` instead of `application/octet-stream` + python -c "import SimpleHTTPServer; import sys; sys.argv = [None, '$port']; SimpleHTTPServer.SimpleHTTPRequestHandler.extensions_map[''] = 'text/plain'; SimpleHTTPServer.test();" } # Test if HTTP compression (RFC 2616 + SDCH) is enabled for a given URL. -- cgit v1.2.3