HttpListener httpListener = new HttpListener();
httpListener.AuthenticationSchemes = AuthenticationSchemes.Anonymous;
httpListener.Prefixes.Add("http://localhost:8080/");
httpListener.Start();
new Thread(new ThreadStart(delegate
{
while (true)
{
HttpListenerContext httpListenerContext = httpListener.GetContext();
httpListenerContext.Response.StatusCode = 200;
httpListenerContext.Response.ContentType = "text/html";
byte[] bytes = File.ReadAllBytes(@"单页文件路径");
httpListenerContext.Response.OutputStream.Write(bytes, 0, bytes.Length);
}
}))
{ IsBackground = true }.Start();