Answered step by step
Verified Expert Solution
Question
1 Approved Answer
#Simple HTTP Web Server #creates Window Tile Description $host.UI.RawUI.WindowTitle = MyPowerShellSite #create http listener $listener = New-Object System.Net.HttpListener #server to listen on URL address
#Simple HTTP Web Server #creates Window Tile Description $host.UI.RawUI.WindowTitle = "MyPowerShellSite" #create http listener $listener = New-Object System.Net.HttpListener #server to listen on URL address localhost on port 8888. You can change the port if you want $listener.Prefixes.Add("http://localhost:8888/") #start the listener $listener.Start() #Sets the www root directory to the current directory #Required to prevent traversal attacks using ..\..\ New-PSDrive -Name MyPowerShellSite -PSProviderFileSystem-Root $PWD.Path #using the get context method to create a synchronous object $Context = $listener.GetContext() #gets the files in the local path and sends to browser $URL = $Context.Request.Url.LocalPath $Content = Get-Content-Encoding Byte -Path "MyPowerShellSite:$URL" $Context.Response.OutputStream.Write($Content, 0, $Content.Length) $Context.Response.Close() N >
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started