using Tesses; using Tesses.WebServer; namespace Tesses.WebServer.ConsoleApp { class MainClass { public static void Main(string[] args) { TestObject some_object = new TestObject(); RouteServer rserver = new RouteServer(); rserver.Add("/", async(ctx) => { await ctx.SendJsonAsync(some_object); }); rserver.Add("/page", async(ctx) => { await ctx.SendTextAsync("Demetria Devonne Lovato 8/20/1992"); }); var ip=System.Net.IPAddress.Any; StaticServer static_server = new StaticServer(System.Environment.GetFolderPath(System.Environment.SpecialFolder.MyVideos)); MountableServer mountable = new MountableServer(static_server); mountable.Mount("/api/",new DynamicServer()); BasicAuthServer basicAuth = new BasicAuthServer((user, pass) => { return user == "demi" && pass == "password123"; }, rserver, "RouteServer"); //bad pasword I know, This is a sample mountable.Mount("/api/route/",basicAuth); HttpServerListener s = new HttpServerListener(new System.Net.IPEndPoint(ip, 24240),mountable); /* So this sample application Route Server (Like dajuric/simple-http's routes (uses modified code from that project)) (In this example It is password protected, Username: "demi", Password: "password123") I know password123 is a bad password (but its ok for this sample project) /api/route/page: shows authors favorite artist and the birthday /api/route/: shows authors name, birthday, gender Dynamic Server (native api) /api/rand: shows how you can use query params /api/count: counts up every time you go to it everything else is files in My Videos */ s.ListenAsync(System.Threading.CancellationToken.None).Wait(); } public class TestObject { public string name => "Mike Nolan"; public int month => 12; public int day => 2; public int year => 2000; public string gender => "Male"; //duh } } }