当前位置: 首页>>代码示例>>C#>>正文


C# HttpServer.Add方法代码示例

本文整理汇总了C#中HttpServer.Add方法的典型用法代码示例。如果您正苦于以下问题:C# HttpServer.Add方法的具体用法?C# HttpServer.Add怎么用?C# HttpServer.Add使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在HttpServer的用法示例。


在下文中一共展示了HttpServer.Add方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Main

        static void Main(string[] args)
        {
            // Template generators are used to render templates 
            // (convert code + html to pure html).
            TemplateManager mgr = new TemplateManager();
            mgr.Add("haml", new HamlGenerator());

            // The httpserver is quite dumb and will only serve http, nothing else.
            HttpServer server  = new HttpServer();

            // a controller mode implements a MVC pattern
            // You'll add all controllers to the same module.
            ControllerModule mod = new ControllerModule();
            mod.Add(new UserController(mgr));
            server.Add(mod);

            // file module will be handling files
            FileModule fh = new FileModule("/", Environment.CurrentDirectory);
            fh.AddDefaultMimeTypes();
            server.Add(fh);

            // Let's start pure HTTP, we can also start a HTTPS listener.
            server.Start(IPAddress.Any, 8081);

            Console.ReadLine();
        }
开发者ID:kf6kjg,项目名称:halcyon,代码行数:26,代码来源:Program.cs

示例2: CreateHTTPServer

 public static void CreateHTTPServer(string filePath, string httpServerPath,
     string PHPCGIPath, uint port, bool allowDirectoryListing)
 {
     HttpServer server = new HttpServer();
     AdvancedFileModule afm = new AdvancedFileModule(httpServerPath, filePath, false, allowDirectoryListing);
     afm.ServeUnknownTypes(true, "php");
     afm.AddCgiApplication("php", PHPCGIPath);
     server.Add(afm);
     server.Start(IPAddress.Any, (int)port);
 }
开发者ID:Gnu32,项目名称:Silverfin,代码行数:10,代码来源:AdvancedFileModule.cs

示例3: Test

        public void Test()
        {
			HttpServer server = new HttpServer();
            server.Add(new SimpleModule());
            server.Start(IPAddress.Any, 8899);
            server.BackLog = 50;

            Thread[] threads = new Thread[ThreadCount];
            for (int i = 0; i < ThreadCount; ++i)
            {
                threads[i] = new Thread(OnSendRequest);
                threads[i].Start(i+1);
            }

            if (!_threadsDoneEvent.WaitOne(60000, true))
                Console.WriteLine("Failed to get all responses.");

            foreach (string s in _failedThreads)
                Console.WriteLine("* Failed thread: " + s);
            if (_failedThreads.Count  > 0)
                Console.WriteLine("* Total: " + _failedThreads.Count);

            Console.ReadLine();
        }
开发者ID:kow,项目名称:Aurora-Sim,代码行数:24,代码来源:HttpServerLoadTests.cs

示例4: Initialize

        public void Initialize()
        {
            if (_server == null)
            {
                _port = getFreePort();

                _server = new HttpServer(new MyLogWriter());

                _server.Add(new MyModule(this));
                _server.Start(IPAddress.Loopback, _port);

                Trace.WriteLine(
                    string.Format(
                        @"[Web server] Started local web server for URL '{0}'.",
                        baseUrl));
            }
        }
开发者ID:iraychen,项目名称:ZetaHtmlEditControl,代码行数:17,代码来源:WebServer.cs


注:本文中的HttpServer.Add方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。