/**
* Uses Nancy self hosting to host the app. To get this working you'll need to
* install the following nuget packages
*
* install-package Nancy.Hosting.Self
*/
using System;
using System.Linq;
using System.Threading;
using Nancy.Hosting.Self;
namespace NancyVagrant
{
class Program
{
static void Main(string[] args)
{
var uri =
new Uri("http://localhost:8888");
using (var host = new NancyHost(uri))
{
host.Start();
Console.WriteLine("Your application is running on " + uri);
Console.WriteLine("Press any [Enter] to close the host.");
//Under mono if you deamonize a process a Console.ReadLine with cause an EOF
//so we need to block another way
if (args.Any(s => s.Equals("-d", StringComparison.CurrentCultureIgnoreCase)))
{
Thread.Sleep(Timeout.Infinite);
}
else
{
Console.ReadKey();
}
}
}
}
}
/**
* Uses Owin HttpListener to host the app. To get this working you'll need to
* install the following nuget packages
*
* install-package Microsoft.Owin.Hosting
* install-package Microsoft.Owin.Host.HttpListener
* install-package Nancy.Owin
*/
using Microsoft.Owin.Hosting;
using Owin;
using System;
using System.Linq;
using System.Threading;
namespace NancyOwin
{
class Program
{
static void Main(string[] args)
{
var uri = "http://localhost:8888";
using (WebApp.Start<Startup>(uri))
{
Console.WriteLine("Your application is running on " + uri);
Console.WriteLine("Press any key to close the host.");
//Under mono if you deamonize a process a Console.ReadLine with cause an EOF
//so we need to block another way
if (args.Any(s => s.Equals("-d", StringComparison.CurrentCultureIgnoreCase)))
{
Thread.Sleep(Timeout.Infinite);
}
else
{
Console.ReadKey();
}
}
}
}
class Startup
{
public void Configuration(IAppBuilder app)
{
app.UseNancy();
}
}
}