Created
September 20, 2016 02:24
-
-
Save erinxocon/f55035b2967c9d12a0c7c407a09a11e7 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
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