Nancy self hosting

One of the great thing about Nan­cy is that you can host it in pret­ty much every­where, and that includes inside a con­sole app! The doc­u­men­ta­tions seems to be miss­ing the self-host­ing option how­ev­er, but it’s easy and only takes a minute.

First, cre­ate a con­sole app and get the Nancy.Hosting.Self pack­age from NuGet:

image

Then you write your mod­ule code and then sim­ply cre­ate an instance of Nan­cy­Host with the base URL you want to use and call the Start() method to start host­ing! It just couldn’t be eas­i­er :-D

Here’s a quick exam­ple:

Enjoy!