1
0
Fork 0

Modify http-server to work with python3

Since python3, the SimpleHTTPServer has been merged as its stated in the [docs](https://docs.python.org/2/library/simplehttpserver.html):

> The SimpleHTTPServer module has been merged into http.server in Python 3. The 2to3 tool will automatically adapt imports when converting your sources to Python 3.

Most systems alias/redirect "python" to the latest python installed:

```
❯❯❯ file /usr/bin/python
/usr/bin/python: symbolic link to `python3'
```

They also kept a `python{2,3}`, depending on the major version even if only one is installed. So, in a system with only `python 2.x, with this change it should still work.

(Another alternative would be run `python2 -m SimpleHTTPServer`.
pull/693/head
Pablo Olmos de Aguilera Corradini 10 years ago
parent 96a0ccd3a1
commit 2aecc91f94

@ -145,7 +145,11 @@ fi
# Miscellaneous
# Serves a directory via HTTP.
if (($+commands[python3]); then
alias http-serve='python -m http.server'
elif (($+commands[python2]); then
alias http-serve='python -m SimpleHTTPServer'
fi
#
# Functions

Loading…
Cancel
Save