Skip to content

Instantly share code, notes, and snippets.

@viovanov
Created August 26, 2015 21:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save viovanov/fadc0268ac6d8d48e492 to your computer and use it in GitHub Desktop.
Save viovanov/fadc0268ac6d8d48e492 to your computer and use it in GitHub Desktop.
one liner to run a web server from a windows command prompt
powershell -command "$l = New-Object System.Net.HttpListener ; $l.Prefixes.Add('http://+:8080/'); $l.Start(); while ($l.IsListening) { $c = $l.GetContext() ; $q = $c.Request; Write-Output (date); $r = $c.Response ; $m = [System.Text.ASCIIEncoding]::ASCII.GetBytes(((gci -path env:*) | Out-String)); $r.ContentLength64 = $m.Length ; $r.OutputStream.Write($m, 0, $m.Length) ; $r.OutputStream.Dispose(); }"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment