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`.
This commit is contained in:
parent
96a0ccd3a1
commit
2aecc91f94
1 changed files with 5 additions and 1 deletions
|
@ -145,7 +145,11 @@ fi
|
|||
# Miscellaneous
|
||||
|
||||
# Serves a directory via HTTP.
|
||||
alias http-serve='python -m SimpleHTTPServer'
|
||||
if (($+commands[python3]); then
|
||||
alias http-serve='python -m http.server'
|
||||
elif (($+commands[python2]); then
|
||||
alias http-serve='python -m SimpleHTTPServer'
|
||||
fi
|
||||
|
||||
#
|
||||
# Functions
|
||||
|
|
Loading…
Add table
Reference in a new issue