Skip to content

Instantly share code, notes, and snippets.

@erinxocon
Created September 20, 2016 02:24
Show Gist options
  • Save erinxocon/f55035b2967c9d12a0c7c407a09a11e7 to your computer and use it in GitHub Desktop.
Save erinxocon/f55035b2967c9d12a0c7c407a09a11e7 to your computer and use it in GitHub Desktop.
using System;
using Nancy.Hosting.Self;
namespace Nancy.Demo.Hosting.Self
{
class Program
{
private string _url = "http://localhost";
private int _port = 12345;
private NancyHost _nancy;
public Program()
{
var configuration = new HostConfiguration() { UrlReservations = new UrlReservations() { CreateAutomatically = true } };
var uri = new Uri($"{_url}:{_port}/");
_nancy = new NancyHost(configuration, uri);
}
private void Start()
{
_nancy.Start();
Console.WriteLine($"Started listennig port {_port}");
Console.ReadKey();
_nancy.Stop();
}
static void Main(string[] args)
{
var p = new Program();
p.Start();
}
}
public class SimpleModule : NancyModule
{
public SimpleModule()
{
Get["/"] = _ => "Received GET request";
Post["/"] = _ => "Received POST request";
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment