What is the Python 3 equivalent of "python -m SimpleHTTPServer" What is the Python 3 equivalent of "python -m SimpleHTTPServer" python python

What is the Python 3 equivalent of "python -m SimpleHTTPServer"


From the docs:

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

So, your command is python -m http.server, or depending on your installation, it can be:

python3 -m http.server


Using 2to3 utility.

$ cat try.pyimport SimpleHTTPServer$ 2to3 try.pyRefactoringTool: Skipping implicit fixer: bufferRefactoringTool: Skipping implicit fixer: idiomsRefactoringTool: Skipping implicit fixer: set_literalRefactoringTool: Skipping implicit fixer: ws_commaRefactoringTool: Refactored try.py--- try.py  (original)+++ try.py  (refactored)@@ -1 +1 @@-import SimpleHTTPServer+import http.serverRefactoringTool: Files that need to be modified:RefactoringTool: try.py

Like many *nix utils, 2to3 accepts stdin if the argument passed is -. Therefore, you can test without creating any files like so:

$ 2to3 - <<< "import SimpleHTTPServer"


matomo