public override void Execute(IDictionary <string, object> input) { var port = input.Get <int>(PORT); var openWindow = input.Get <bool>(OPEN_WINDOW); if (_localWebServer.IsStarted) { _console.WriteError("Local web server has been already started"); _localWebServer.Stop(); return; } var config = new LocalWebServerConfig { Port = port }; _localWebServer.Start(config); if (openWindow) { var url = $"http://localhost:{config.Port}"; UtilSystem.OpenUrl(url); } _console.WriteSuccess("Local web server started successfully"); }
private Task StartWebMode(WebOptions options) { var config = new LocalWebServerConfig { Port = options.Port }; var tokenSource = new CancellationTokenSource(); var token = new CancellationToken(); /*var task = */ _localWebServer.RunAsync(config, token); UtilConsole.WriteSuccess("Local server started. Press <Enter> to stop..."); if (options.OpenWindow) { var url = $"http://localhost:{config.Port}"; UtilSystem.OpenUrl(url); } Console.ReadLine(); Console.WriteLine("Stopping local server..."); _localWebServer.Stop(); tokenSource.Cancel(); return(Task.CompletedTask); }