等价物是:
python3 -m http.server
使用2to3实用程序。
$ cat try.py
import SimpleHTTPServer
$ 2to3 try.py
RefactoringTool: Skipping implicit fixer: buffer
RefactoringTool: Skipping implicit fixer: idioms
RefactoringTool: Skipping implicit fixer: set_literal
RefactoringTool: Skipping implicit fixer: ws_comma
RefactoringTool: Refactored try.py
--- try.py (original)
+++ try.py (refactored)
@@ -1 +1 @@
-import SimpleHTTPServer
+import http.server
RefactoringTool: Files that need to be modified:
RefactoringTool: try.py
如果您必须使用不同的端口,请使用:
python -m http.server 8080
除了Petr的回答,如果你想绑定到一个特定的接口,而不是所有的接口,你可以使用-b / – bind标志。
python -m http.server 8000 --bind 127.0.0.1
上面的代码片段应该做到这一点。8000是端口号。80被用作HTTP通信的标准端口。