nancy框架hosting.self

nancy框架hosting.self框架

1、新建控制台应用程序spa

2、使用NuGet安装nancy.hosting.selfcode

3、监听服务,打开Program.cs文件编辑路由

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Nancy;
using Nancy.Hosting.Self;

namespace test1
{
    class Program
    {
        static void Main(string[] args)
        {
            string uri = "http://127.0.0.1:9090";
            using(var host = new NancyHost(new Uri(uri)))
            {
                host.Start();
                Console.WriteLine("服务启动:地址 "+uri);
                Console.Read();
                host.Stop();
            }
        }
    }
}

4、路由编写string

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Nancy;

namespace test1.Router
{
    public class Router : NancyModule
    {
        public Router()
        {
            Get["/"] = _ =>
            {
                return "hello world";
            };
        }
    }
    
}
相关文章
相关标签/搜索