Python http.server 不打印日志
Python http.server not print log
我正在使用 Git Bash 到 运行 一个简单的本地服务器 $ python3 -m http.server 8000
Git Bash 从不打印它是 运行ning 并且不获取请求日志。我可以访问 http://localhost:8000/ 所以该命令正在运行。如何让 git bash 打印日志?
从"what"GitBash来看,好像是cygwin的精简版。我刚刚 运行 "python3 -m http.server 8000",并得到以下日志输出:
$ python3 -m http.server 8000
Serving HTTP on 0.0.0.0 port 8000 (http://0.0.0.0:8000/) ...
127.0.0.1 - - [04/Jun/2017 20:15:10] "GET / HTTP/1.1" 200 -
127.0.0.1 - - [04/Jun/2017 20:15:10] code 404, message File not found
127.0.0.1 - - [04/Jun/2017 20:15:10] "GET /favicon.ico HTTP/1.1" 404 -
127.0.0.1 - - [04/Jun/2017 20:15:10] code 404, message File not found
127.0.0.1 - - [04/Jun/2017 20:15:10] "GET /favicon.ico HTTP/1.1" 404 -
git bash 似乎没有正确记录(输出)。
在 virtualbox / vagrant -> 使用 Ubuntu 或 Centos 中尝试 运行ning "python3 -m http.server 8000"。
这似乎是 mingw 下行缓冲的普遍问题。您应该能够通过避免缓冲输出来解决此问题,在您的情况下可以通过
$ python -u -m http.server 8080
这在
上按预期工作
$ uname -a
MINGW64_NT-6.3 - 2.5.0(0.295/5/3) 2016-03-31 18:47 x86_64 Msys
我正在使用 Git Bash 到 运行 一个简单的本地服务器 $ python3 -m http.server 8000
Git Bash 从不打印它是 运行ning 并且不获取请求日志。我可以访问 http://localhost:8000/ 所以该命令正在运行。如何让 git bash 打印日志?
从"what"GitBash来看,好像是cygwin的精简版。我刚刚 运行 "python3 -m http.server 8000",并得到以下日志输出:
$ python3 -m http.server 8000
Serving HTTP on 0.0.0.0 port 8000 (http://0.0.0.0:8000/) ...
127.0.0.1 - - [04/Jun/2017 20:15:10] "GET / HTTP/1.1" 200 -
127.0.0.1 - - [04/Jun/2017 20:15:10] code 404, message File not found
127.0.0.1 - - [04/Jun/2017 20:15:10] "GET /favicon.ico HTTP/1.1" 404 -
127.0.0.1 - - [04/Jun/2017 20:15:10] code 404, message File not found
127.0.0.1 - - [04/Jun/2017 20:15:10] "GET /favicon.ico HTTP/1.1" 404 -
git bash 似乎没有正确记录(输出)。
在 virtualbox / vagrant -> 使用 Ubuntu 或 Centos 中尝试 运行ning "python3 -m http.server 8000"。
这似乎是 mingw 下行缓冲的普遍问题。您应该能够通过避免缓冲输出来解决此问题,在您的情况下可以通过
$ python -u -m http.server 8080
这在
上按预期工作$ uname -a
MINGW64_NT-6.3 - 2.5.0(0.295/5/3) 2016-03-31 18:47 x86_64 Msys