Last Updated: June 16, 2017
·
3.862K
· ohiocowboy

Python simple HTTP web server with logging output

  • Start up a simple HTTP server, serving the files in the current working directory
  • Open your default browser
  • Getting logging output in the console
local port="${1:-8000}";
sleep 1 && open "http://0.0.0.0:${port}/" &
python -c $'import SimpleHTTPServer;\nmap = SimpleHTTPServer.SimpleHTTPRequestHandler.extensions_map;\nmap[""] = "text/plain";\nfor key, value in map.items():\n\tmap[key] = value + ";charset=UTF-8";\nSimpleHTTPServer.test();' "$port";