/// <summary> /// Load WebServer instance /// </summary> /// <param name="args"></param> private static void Main(string[] args) { var options = new Options(); Console.WriteLine("Unosquare.Labs.EmbedIO Web Server"); if (!Parser.Default.ParseArguments(args, options)) return; Console.WriteLine(" Command-Line Utility: Press any key to stop the server."); using (var server = WebServer.CreateWithConsole("http://localhost:" + options.Port + "/")) { if (Properties.Settings.Default.UseLocalSessionModule) server.WithLocalSession(); server.EnableCors().WithStaticFolderAt(options.RootPath, defaultDocument: Properties.Settings.Default.HtmlDefaultDocument); server.Module<StaticFilesModule>().DefaultExtension = Properties.Settings.Default.HtmlDefaultExtension; server.Module<StaticFilesModule>().UseRamCache = Properties.Settings.Default.UseRamCache; if (options.ApiAssemblies != null && options.ApiAssemblies.Count > 0) { foreach (var api in options.ApiAssemblies) { server.Log.DebugFormat("Registering Assembly {0}", api); LoadApi(api, server); } } // start the server server.RunAsync(); Console.ReadKey(true); } }
/// <summary> /// Load WebServer instance /// </summary> /// <param name="args"></param> private static void Main(string[] args) { var options = new Options(); CurrentApp.WriteWelcomeBanner(); if (!Swan.Runtime.ArgumentParser.Default.ParseArguments(args, options)) return; " Command-Line Utility: Press any key to stop the server.".Info(); var serverUrl = "http://localhost:" + options.Port + "/"; using (var server = new WebServer(serverUrl)) { // TODO: Add AppSettings file //if (Properties.Settings.Default.UseLocalSessionModule) server.WithLocalSession(); server.EnableCors().WithStaticFolderAt(options.RootPath); //server.EnableCors().WithStaticFolderAt(options.RootPath, // defaultDocument: Properties.Settings.Default.HtmlDefaultDocument); //server.Module<StaticFilesModule>().DefaultExtension = Properties.Settings.Default.HtmlDefaultExtension; //server.Module<StaticFilesModule>().UseRamCache = Properties.Settings.Default.UseRamCache; if (string.IsNullOrEmpty(options.ApiAssemblies)) { $"Registering Assembly {options.ApiAssemblies}".Debug(); LoadApi(options.ApiAssemblies, server); } // start the server server.RunAsync(); Terminal.ReadKey(true); } }