Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Python http.server not print log

I am using Git Bash to run a simple local server with $ python3 -m http.server 8000

Git Bash never prints that it is running and does not get a log of the requests. I can access http://localhost:8000/ so the command is working. How do I get git bash to print the log?

like image 858
Estevan Gonzalez Avatar asked Jun 04 '17 19:06

Estevan Gonzalez


2 Answers

This appears to be a general issue with line-buffering under mingw. You should be able to work around this by avoiding buffering the outputs, which in your case is possible through

$ python -u -m http.server 8080

This works as expected on

$ uname -a
MINGW64_NT-6.3 - 2.5.0(0.295/5/3) 2016-03-31 18:47 x86_64 Msys
like image 81
fuglede Avatar answered Oct 23 '22 04:10

fuglede


From looking at "what" Git Bash, it would seem to be a cut down version of cygwin. I have just run "python3 -m http.server 8000", and get the following log output:

$ 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 -

It would seem that git bash is not logging (outputting) correctly.

Trying running "python3 -m http.server 8000" in virtualbox / vagrant -> with Ubuntu or Centos.

like image 44
chocksaway Avatar answered Oct 23 '22 02:10

chocksaway