Answered step by step
Verified Expert Solution
Link Copied!

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

image text in transcribed

#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

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Introduction To Computing And Programming In Python A Multimedia Approach

Authors: Mark J. Guzdial, Barbara Ericson

4th Edition

0134025547, 978-0134025544

More Books

Students also viewed these Computer Network questions

Question

How do internal reports differ from external reports?

Answered: 1 week ago