aboutsummaryrefslogtreecommitdiffstats
path: root/.functions
diff options
context:
space:
mode:
authorMathias Bynens <mathias@qiwi.be>2012-01-09 14:34:38 +0100
committerMathias Bynens <mathias@qiwi.be>2012-01-09 14:34:38 +0100
commit27c2285c59d72c01b69d4e57e5cfc78130f2370d (patch)
tree10baef425959936d59ef47939c245e069b175f45 /.functions
parentb2e13d33a4fae5c0d3531dd929c8521e3fc57481 (diff)
downloaddotfiles-27c2285c59d72c01b69d4e57e5cfc78130f2370d.tar.gz
dotfiles-27c2285c59d72c01b69d4e57e5cfc78130f2370d.tar.bz2
dotfiles-27c2285c59d72c01b69d4e57e5cfc78130f2370d.zip
`server` function: Serve everything as UTF-8
Even though this is not technically correct for binary files, it doesn’t actually break anything.
Diffstat (limited to '.functions')
-rw-r--r--.functions3
1 files changed, 2 insertions, 1 deletions
diff --git a/.functions b/.functions
index 0ae79c9..5b7b8e3 100644
--- a/.functions
+++ b/.functions
@@ -8,7 +8,8 @@ function server() {
local port="${1:-8000}"
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;charset=UTF-8'; SimpleHTTPServer.test();"
+ # 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"
}
# Test if HTTP compression (RFC 2616 + SDCH) is enabled for a given URL.