Skip to content

Instantly share code, notes, and snippets.

@theburningmonk
Created September 2, 2011 10:57
Show Gist options
  • Save theburningmonk/1188378 to your computer and use it in GitHub Desktop.
Save theburningmonk/1188378 to your computer and use it in GitHub Desktop.
Nancy self-hosting example
// a simple module to be hosted in the console app
public class MainModule : NancyModule
{
public MainModule()
{
Get["/"] = x => { return "Hello World"; };
}
}
static void Main(string[] args)
{
// initialize an instance of NancyHost (found in the Nancy.Hosting.Self package)
var host = new NancyHost(new Uri("http://localhost:12345"));
host.Start(); // start hosting
Console.ReadKey();
host.Stop(); // stop hosting
}
@zgrkpnr
Copy link

zgrkpnr commented Oct 26, 2017

Where do you use MainModule ? Why did you define it if you don't use it.

@sam453
Copy link

sam453 commented Nov 14, 2017

Nancy automatically discovers all modules so we don’t have to register them.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment