Skip to content

Repository files navigation

MonkeyWebServer

A Csharp WebServer powered by Monke.

  • Template Rendering using Scriban.
  • Json responses using NewtonsoftJson.
  • Easy routing.
  • cool dev errors.

monkeerror img

Usage

  • Install
  • uuuuuuuuaaaaaa uuu uuu aaa - monkey response
publicclassProg{publicstaticvoidMain(string[]args){MonkeyEndpoints.AddEndpoint(newExampleEndpoint());MonkeyEndpoints.AddEndpoint(newExampleJsonEndpoint());MonkeyServer.StartServer(true);MonkeyServer.AddPrefix("http://localhost:8000/");Task.Run(MonkeyServer.HandleIncomingConnections);Console.ReadKey();MonkeyServer.StopServer();}}publicclassExampleEndpoint:MonkeyEndpoint{publicoverridestringEndpoint{get=>"/test";}publicoverrideMonkeyResponseExecute(HttpListenerContextctx){varProductList=newList<dynamic>{new{name="Product 1",price=10.99,description="Lorem ipsum dolor sit amet"},new{name="Product 2",price=19.99,description="Consectetur adipiscing elit"},new{name="Product 3",price=5.99,description="Sed do eiusmod tempor"},new{name="Product 4",price=5.2449,description="Sedo do edsdiusmod tempor"},};returnMonkeyResponse.RenderTemplate(ctx.Response,"./templates/test.html",new{Products=ProductList});}}publicclassExampleJsonEndpoint:MonkeyEndpoint{publicoverridestringEndpoint{get=>"/testjson";}publicoverrideMonkeyResponseExecute(HttpListenerContextctx){varProductList=newList<dynamic>{new{name="Product 1",price=10.99,description="Lorem ipsum dolor sit amet"},new{name="Product 2",price=19.99,description="Consectetur adipiscing elit"},new{name="Product 3",price=5.99,description="Sed do eiusmod tempor"},new{name="Product 4",price=5.2449,description="Sedo do edsdiusmod tempor"},};returnMonkeyResponse.Json(ctx.Response,ProductList);}}

License

This project is licensed under the MIT License.

About

A Csharp WebServer Powered By Monke

Topics

Resources

Stars

0 stars

Watchers

1 watching

Forks

Releases

Packages

Used by

Contributors

Languages