Using System;
Using System. Collections. Generic;
Using System. LINQ;
Using System. text;
Using System. net;
Using System. net. Sockets;
Using System. IO;
Namespace Leleapphttplistener
{
/// <Summary>
/// Listen for HTTP requests by rhythmk
/// </Summary>
Class Program
{
Static Void Main ( String [] ARGs)
{
Listenerhttpurl ();
Console. readkey ();
}
Static Void Listenerhttpurl ()
{
String Url = " Http://admin2.rhytmk.t/rhythmk/ " ;
Using (Httplistener hlistener = New Httplistener ())
{
// Anonymous Access
Hlistener. authenticationschemes = authenticationschemes. Anonymous;
Hlistener. prefixes. Add (URL );
// Hlistener. prefixes. Add ("url2 ")
Hlistener. Start ();
Console. writeline ( " --- Start ---- " );
While ( True )
{
Httplistenercontext hlcontext = hlistener. getcontext ();
Hlcontext. response. statuscode = 200 ;
String Key = hlcontext. Request. querystring [ " Key " ];
If (! String . Isnullorempty (key ))
{
Console. writeline ( String . Format ( " The key is {0}, time: {1} " , Key, datetime. Now ));
}
// Close request
Hlcontext. response. Close ();
// OUTPUT response html Structure
// Using (streamwriter writer = new streamwriter (hlcontext. response. outputstream ))
// {
// Writer. writeline ("true ");
// Writer. Close ();
// Hlcontext. response. Close ();
// }
}
}
}
}
}