Facebook
From czy, 1 Year ago, written in PowerShell.
Embed
Download Paste or View Raw
Hits: 77
  1. $Hso = New-Object Net.HttpListener
  2. $Hso.Prefixes.Add("http://+:8000/")
  3. $Hso.Start()
  4. While ($Hso.IsListening) {
  5.     $HC = $Hso.GetContext()
  6.     $HRes = $HC.Response
  7.     $HRes.Headers.Add("Content-Type","text/plain")
  8.     $Buf = [Text.Encoding]::UTF8.GetBytes((GC (Join-Path $Pwd ($HC.Request).RawUrl)))
  9.     $HRes.ContentLength64 = $Buf.Length
  10.     $HRes.OutputStream.Write($Buf,0,$Buf.Length)
  11.     $HRes.Close()
  12. }
  13. $Hso.Stop()