Facebook

Code:

            static class Program
            {
                /// 
                /// The main entry point for the application.
                /// 
                static NancyHost host;
                public class SampleModule : Nancy.NancyModule
                {
                    public SampleModule() : base("/Sample")
                    {
                        Get("/", _ => "Hello World!");
                    }
                }
                public class MainModule : Nancy.NancyModule
                {
                    public MainModule() : base("/")
                    {
                        Get("/", _ => {
                            return "Hello Base!";
                        });
    
                        Get("/View", _ =>
                        {
                            return View["WebView/Index.html"];
                        });
                    }
                }
                public class Bootstrapper : DefaultNancyBootstrapper
                {
                    /// 
                    /// Register only NancyModules found in this assembly
                    /// 
                    protected override IEnumerable Modules
                    {
                        get
                        {
                            return GetType().Assembly.GetTypes().Where(type => type.BaseType == typeof(NancyModule)).Select(type => new ModuleRegistration(type));
                        }
                    }
    
                    protected override void ConfigureConventions(NancyConventions conventions)
                    {
                        conventions.StaticContentsConventions.Add(
                            StaticContentConventionBuilder.AddDirectory("WebView", @"/WebView/")
                        );
                        base.ConfigureConventions(conventions);
                    }
                }
    
                [STAThread]
                static void Main()
                {
                    var host = new NancyHost(new Bootstrapper(), new Uri("http://localhost:8080"));
                    host.Start(); // start hosting
    
                    Application.EnableVisualStyles();
                    Application.SetCompatibleTextRenderingDefault(false);
                    Application.Run(new Form1());
                }
            }
            

Leave a Reply

Your email address will not be published. Required fields are marked *