aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMathias Bynens <mathias@qiwi.be>2011-12-31 15:41:21 +0100
committerMathias Bynens <mathias@qiwi.be>2011-12-31 15:41:21 +0100
commitc1c05cb460d88c6611f18265b485e0e90c3b45c9 (patch)
tree2aae8fd602e520b89eb54fc24139d946a43c3d68
parent9850a48f18c5cf03ef0d5e95f63be3c745279f7d (diff)
downloaddotfiles-c1c05cb460d88c6611f18265b485e0e90c3b45c9.tar.gz
dotfiles-c1c05cb460d88c6611f18265b485e0e90c3b45c9.tar.bz2
dotfiles-c1c05cb460d88c6611f18265b485e0e90c3b45c9.zip
`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
-rw-r--r--.functions4
1 files changed, 3 insertions, 1 deletions
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.