Created
September 2, 2011 10:57
-
-
Save theburningmonk/1188378 to your computer and use it in GitHub Desktop.
Nancy self-hosting example
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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 | |
} |
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
Where do you use MainModule ? Why did you define it if you don't use it.