Пример #1
0
 private void Button_Click(object sender, RoutedEventArgs e)
 {
     if (_server == null)
     {
         _server = new SimpleHTTPServer(null, 80, RequestHandler);
         System.Diagnostics.Process.Start("http://localhost");
     }
 }
Пример #2
0
 public override void Start()
 {
     if (_type == WallpaperType.Web)
     {
         _server = new SimpleHTTPServer(_uri, _port);
     }
     _browser.Show();
 }
    void Start()
    {
        var appPath = Application.dataPath;
        var wwwPath = appPath.Substring(0, appPath.LastIndexOf("Assets")) + "www";

        _server = new SimpleHTTPServer(wwwPath, 8080);
        Debug.Log("Starting web server...");
    }
Пример #4
0
        public void SetUp()
        {
            // check that the process can create web servers
            bool isProcessElevated = ElevationChecker.IsProcessElevated(false);

            Assert.IsTrue(isProcessElevated, "This test needs to run from an elevated IDE or nunit console");

            // initialize custom HttpListener subclass to host the local files
            // https://docs.microsoft.com/en-us/dotnet/api/system.net.httplistener?redirectedfrom=MSDN&view=netframework-4.7.2
            String filePath = System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().GetName().CodeBase).Replace("file:\\", "");

            // Console.Error.WriteLine(String.Format("Using Webroot path: {0}", filePath));
            pageServer = new SimpleHTTPServer(filePath);
            // implicitly does pageServer.Initialize() and  pageServer.Listen();
            Common.Port = pageServer.Port;

            /*
             * // options.IsMarionette = true;
             * // There is already an option for the marionette capability. Please use the  instead.
             * // options.AddAdditionalCapability("marionette", true);
             * // options.IsMarionette = true;
             * // There is already an option for the marionette capability. Please use the  instead.
             * // options.AddAdditionalCapability("marionette", true);
             * // DesiredCapabilities capabilities = DesiredCapabilities.Firefox();
             * // capabilities.SetCapability("marionette", true);
             */
            // String projectDirectory = System.IO.Directory.GetCurrentDirectory();

            //FirefoxOptions options = new FirefoxOptions();
            //options.UseLegacyImplementation = true;
            //System.Environment.SetEnvironmentVariable("webdriver.gecko.driver", String.Format(@"{0}\geckodriver.exe", System.IO.Directory.GetCurrentDirectory()));
            // driver = new FirefoxDriver(options);

            //		driver = new ChromeDriver(System.IO.Directory.GetCurrentDirectory());
            if (headless)
            {
                var option = new ChromeOptions();
                option.AddArgument("--headless");
                driver = new ChromeDriver(option);
            }
            else
            {
                driver = new ChromeDriver();
            }

            driver.Manage().Timeouts().AsynchronousJavaScript = TimeSpan.FromSeconds(60);
            // driver.Manage().Timeouts().SetScriptTimeout(TimeSpan.FromSeconds(60));
            driver.Manage().Window.Size = new System.Drawing.Size(700, 400);
            Common.NgDriver = ngDriver = new NgWebDriver(driver);
            driver.Manage().Window.Size = new System.Drawing.Size(window_width, window_heght);
            wait = new WebDriverWait(driver, TimeSpan.FromSeconds(wait_seconds));

            // ngDriver.Navigate().GoToUrl(base_url);
            // Tests will fail due to page redesign	- use the
            Common.GetLocalHostPageContent("ng_datepicker.htm");

            actions = new Actions(driver);
        }
Пример #5
0
 //
 //
 //
 private void ServerStop()
 {
     if (server != null)
     {
         server.Stop();
         updateServerState(0);
         server = null;
     }
 }
Пример #6
0
        private int startServer()
        {
            ActualPort = SimpleHTTPServer.GetOpenPort(this.Settings.WebServerListenPort);

            string hostDirectory = ResolveExoUrlPath(this.Settings.WebServerHostDirectory);

            simpleServer = new SimpleHTTPServer(this, this.Settings, hostDirectory, ActualPort, mappings);

            return(ActualPort);
        }
Пример #7
0
        static void Main(string[] args)
        {
            Console.WriteLine(@"Enter path to site (ex. D:\site):");
            string           x        = Console.ReadLine();
            string           myFolder = x;
            SimpleHTTPServer myServer = new SimpleHTTPServer(myFolder, 80);

            Console.WriteLine("Server is running on this port: " + myServer.Port);
            Console.ReadLine();
        }
Пример #8
0
        //Stop HTTP server
        private void StopHTTP()
        {
            if (serverHTTP != null)
            {
                serverHTTP.Stop();
                serverHTTP = null;

                Log("HTTP server stopped");
            }
        }
Пример #9
0
    static void Main(string[] args)
    {
        var server = new SimpleHTTPServer(args[0], 8088);

        server.Listen();
        // Console.WriteLine("Listening to  port: " + server.Port.ToString());
        // Console.WriteLine("A simple webserver. Press a key to quit.");
        //  Console.ReadKey();
        //  server.Stop();
    }
 void Awake()
 {
     if (_server == null)
     {
         var appPath = Application.dataPath;
         wwwPath = appPath + "/TestWebserverRoot";
         _server = new SimpleHTTPServer(wwwPath, PORT);
         Debug.Log("Starting web server... (" + wwwPath + ")");
     }
 }
Пример #11
0
        /// <summary>
        /// 启动一个简单的http服务,只能处理静态资源
        /// </summary>
        /// <param name="args"></param>
        static void Main(string[] args)
        {
            string myFolder = @"F:\HD";

            //create server with auto assigned port
            SimpleHTTPServer myServer = new SimpleHTTPServer(myFolder);

            Console.WriteLine(myServer.Port);
            Console.ReadKey();
        }
Пример #12
0
        static void Main(string[] args)
        {
            int port = 8080;

            if (args.Length >= 1)
            {
                port = int.Parse(args[0]);
            }
            Console.WriteLine("Starting HTTP Server on port : {0}", port.ToString());
            SimpleHTTPServer server = new SimpleHTTPServer(".", port);
        }
Пример #13
0
        static void Main(string[] args)
        {
            Console.WriteLine("Enter Port");
            var           port   = Console.ReadLine();
            ExampleAction action = new ExampleAction();


            SimpleHTTPServer server = new SimpleHTTPServer(".", int.Parse(port));

            server.AddRoute("hello", action);
        }
 void SwitchHosting()
 {
     if (hosting)
     {
         StopServer();
         httpServer = new SimpleHTTPServer(DocWebPath, httpPort, 32);
     }
     else
     {
         StopServer();
     }
 }
        public MainWindow()
        {
            InitializeComponent();
            this.Topmost = true;
            System.Windows.Threading.DispatcherTimer dispatcherTimer = new System.Windows.Threading.DispatcherTimer();
            dispatcherTimer.Tick    += new EventHandler(dispatcherTimer_Tick);
            dispatcherTimer.Interval = new TimeSpan(0, 0, 1);
            dispatcherTimer.Start();

            wih        = new WindowInteropHelper(this);
            httpServer = new SimpleHTTPServer(8053, this);
        }
Пример #16
0
        public static void Main(String[] args)
        {
            Console.WriteLine("Starting HTTP Server. ");
            Console.WriteLine("Accepting HTTP requests at http://localhost:8081/");
            httpServer = new SimpleHTTPServer("", 8081);

            PoDServer podserver = new PoDServer();
            Thread podthread = new Thread(podserver.ServerMethod);
            podserver.ProcessPackets(httpServer.packetsServer);
            podthread.Start();
            Console.WriteLine("Press CTRL C to exit HTTPServer.");
            podthread.Join();
            httpServer._serverThread.Join();
        }
Пример #17
0
        static void Main()
        {
            AppDomain.CurrentDomain.UnhandledException += CurrentDomain_UnhandledException;
            Application.ThreadException += Application_ThreadException;

            Task.Factory.StartNew(() =>
            {
                SimpleHTTPServer.GetOrStartDefaultServer();
            });

            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);
            Application.Run(new MainForm());
        }
Пример #18
0
        public CodeEditor()
        {
            InitializeComponent();
            var monacoFolder = Path.Combine(Path.GetDirectoryName(ExcelDna.Integration.ExcelDnaUtil.XllPath), "Monaco");

            monacoServer = new SimpleHTTPServer(monacoFolder);
            var monacoUrl = "http://localhost:" + monacoServer.Port.ToString();

            webView1.Source = new Uri(monacoUrl);

            webView1.NavigationStarting  += WebView1_NavigationStarting;
            webView1.NavigationCompleted += WebView1_NavigationCompleted;
            webView1.ScriptNotify        += WebView1_ScriptNotify;
        }
Пример #19
0
        public static void Main(String[] args)
        {
            Console.WriteLine("Starting HTTP Server. ");
            Console.WriteLine("Accepting HTTP requests at http://localhost:8081/");
            httpServer = new SimpleHTTPServer("", 8081);

            PoDServer podserver = new PoDServer();
            Thread    podthread = new Thread(podserver.ServerMethod);

            podserver.ProcessPackets(httpServer.packetsServer);
            podthread.Start();
            Console.WriteLine("Press CTRL C to exit HTTPServer.");
            podthread.Join();
            httpServer._serverThread.Join();
        }
Пример #20
0
        private void initialize(string ip)
        {
            if (Path == null)
            {
                throw new ArgumentNullException();
            }
            if (Url == null)
            {
                throw new ArgumentNullException();
            }

            server  = new SimpleHTTPServer(Path);
            this.IP = IPAddress.Parse(ipService.GetIPAddress(ip).ipAddress);

            CreateProxyAndAddHostFileEntry(IP.ToString(), server.Port, Url);
        }
Пример #21
0
 public void Evaluate(int SpreadMax)
 {
     if (FStart[0])
     {
         _httpServer?.Stop();
         if (FPort[0] <= 0)
         {
             _httpServer = new SimpleHTTPServer(FDir[0]);
         }
         else
         {
             _httpServer = new SimpleHTTPServer(FDir[0], FPort[0]);
         }
         FPortOut[0] = _httpServer.Port;
         FurlOut[0]  = $"http://localhost:{_httpServer.Port}/";
     }
 }
Пример #22
0
        public void SetupWebServer()
        {
            string current = System.IO.Directory.GetCurrentDirectory();

            try
            {
                server = new SimpleHTTPServer(current + "//web", AppSettings.Default.ListenerPort);
            }
            catch (Exception)
            {
                // This can happen if the port is in use. Wittypi for instance uses 8000.  If this happens, message the user and try 5053 to try to reduce
                // the chances of a collision....and to give them a chance to pick one of thier own.
                Logger.LogComment("Error trying to start on default port!  Please set a new port in appsettings.json. Going to try again using Port 5053");
                AppSettings.Default.ListenerPort = 5053;
                server = new SimpleHTTPServer(current + "//web", AppSettings.Default.ListenerPort);
            }
        }
Пример #23
0
	void Start () {
		var wsPort = 8090;
		var httpPort = 8080;

		socketServer = new WebSocketServer (wsPort);
		socketServer.AddWebSocketService<ControlService> ("/control", () => {
			return new ControlService(configurator);
		});
		socketServer.Start ();

		httpServer = new SimpleHTTPServer (Path.Combine(Application.dataPath, "Scripts/Control/.frontend"), httpPort);

		IPHostEntry host;
		host = Dns.GetHostEntry(Dns.GetHostName());
		var localIP = host.AddressList.FirstOrDefault(ip => ip.AddressFamily == System.Net.Sockets.AddressFamily.InterNetwork);
		Debug.Log("Server running on " + localIP + ":" + httpPort);
	}
Пример #24
0
        protected override void OnStart(string[] args)
        {
            // Update the service state to Start Pending after 10 sec.
            ServiceStatus serviceStatus = new ServiceStatus();

            serviceStatus.dwCurrentState = ServiceState.SERVICE_START_PENDING;
            serviceStatus.dwWaitHint     = 10000;
            SetServiceStatus(this.ServiceHandle, ref serviceStatus);

            //create server with auto assigned port
            myServer = new SimpleHTTPServer(RECORDER_DATA, RECORDER_CAMS, EVENT_LOG, CURRENT_DIR, CURRENT_INT_DIR);
            EVENT_LOG.WriteEntry("Сервер регистратора запущен, порт - " + myServer.Port.ToString());

            // Update the service state to Running.
            serviceStatus.dwCurrentState = ServiceState.SERVICE_RUNNING;
            SetServiceStatus(this.ServiceHandle, ref serviceStatus);

            EVENT_LOG.WriteEntry("Служба успешно запущена");
        }
Пример #25
0
        //
        //
        //
        private void ServerStart()
        {
            Int16 port;

            if (Int16.TryParse(ServerPort_textBox.Text, out port) == false)
            {
                port = 8080;
                ServerPort_textBox.Text = port.ToString();
            }

            try
            {
                server = new SimpleHTTPServer(ServerPath_textBox.Text, port);
                updateServerState(1);
            }
            catch (Exception ex)
            {
                Console.WriteLine("Failed to start server {0}", ex.Message);
                server = null;
                updateServerState(-1);
            }
        }
Пример #26
0
        public void SetUp()
        {
            // check that the process can create web servers
            bool isProcessElevated = ElevationChecker.IsProcessElevated(false);

            Assert.IsTrue(isProcessElevated, "This test needs to run from an elevated IDE or nunit console");

            // initialize custom HttpListener subclass to host the local files
            // https://docs.microsoft.com/en-us/dotnet/api/system.net.httplistener?redirectedfrom=MSDN&view=netframework-4.7.2
            String filePath = System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().GetName().CodeBase).Replace("file:\\", "");

            // Console.Error.WriteLine(String.Format("Using Webroot path: {0}", filePath));
            pageServer = new SimpleHTTPServer(filePath);
            // implicitly does pageServer.Initialize() and  pageServer.Listen();
            Common.Port = pageServer.Port;
            // Console.Error.WriteLine(String.Format("Using Port {0}", port));

            // initialize the Selenium driver
            // driver = new FirefoxDriver();
            // System.InvalidOperationException : Access to 'file:///...' from script denied (UnexpectedJavaScriptError)
            if (headless)
            {
                var option = new ChromeOptions();
                option.AddArgument("--headless");
                driver = new ChromeDriver(option);
            }
            else
            {
                driver = new ChromeDriver();
            }
            driver.Manage().Timeouts().AsynchronousJavaScript = TimeSpan.FromSeconds(60);

            Common.NgDriver      = ngDriver = new NgWebDriver(driver);
            wait                 = new WebDriverWait(driver, TimeSpan.FromSeconds(wait_seconds));
            wait.PollingInterval = TimeSpan.FromMilliseconds(wait_poll_milliseconds);
            actions              = new Actions(driver);
        }
Пример #27
0
 private void button1_Click(object sender, EventArgs e)
 {
     server           = new SimpleHTTPServer("D:/Github/executive-functions/public", 3445);
     this.FormClosed += new FormClosedEventHandler(this.Form1_Closed);
 }
Пример #28
0
        void MainWindow_Loaded(object sender, RoutedEventArgs e)
        {
            // Initialize:
            _url              = null;
            _website          = null;
            _simpleHttpServer = null;
            _firewallRuleName = null;

            // Show the "Loading..." page:
            this.MainContainer.Child = new PageWhenLoading();

            // Read the input parameters:
            string[] args = Environment.GetCommandLineArgs();
            if (args.Length >= 3)
            {
                string localhostOrNotArgument = args[1];
                string outputPathAbsolute     = args[2].Trim('"');

                // Determine if we should use "localhost" or the machine IP:
                bool useLocalhost = (localhostOrNotArgument == "uselocalhost" ? true : false);

                // Determine the IP address to use:
                string ipAddressToUse   = null;
                string exceptionMessage = null;
                bool   cancel           = false;
                if (useLocalhost)
                {
                    ipAddressToUse = "localhost";
                }
                else
                {
                    try
                    {
                        ipAddressToUse = IPHelper.GetLocalIPAddress();
                    }
                    catch (Exception ex)
                    {
                        exceptionMessage = "Error while attempting to determine the machine IP address:\r\n\r\n" + ex.Message;
                    }
                }

                // Start the web server:
                if (ipAddressToUse != null)
                {
                    _url = null;
                    try
                    {
                        //create server with given port:
                        if (useLocalhost)
                        {
                            _simpleHttpServer = new SimpleHTTPServer(outputPathAbsolute);
                            _url = "http://" + ipAddressToUse + ":" + _simpleHttpServer.Port.ToString() + "/";
                        }
                        else
                        {
                            //var ipByteArray = IPAddress.Parse(ipAddressToUse).GetAddressBytes();
                            //_simpleHttpServer = new SimpleHTTPServer(outputDir, ipByteArray);

                            _website = Website.Create(outputPathAbsolute, ip: ipAddressToUse);
                            _website.Start();
                            _url = _website.Url;
                            if (!string.IsNullOrEmpty(ipAddressToUse))
                            {
                                _url = _url.Replace("localhost", ipAddressToUse).Replace("127.0.0.1", ipAddressToUse);
                            }
                        }
                    }
                    catch (Exception ex)
                    {
                        if (ex.Message.Contains("REGDB_E_CLASSNOTREG"))
                        {
                            cancel                   = true;
                            _website                 = null;
                            _simpleHttpServer        = null;
                            this.MainContainer.Child = new PageWhenIISNotInstalled();
                        }
                        else
                        {
                            exceptionMessage = "Error while attempting to start the web server:\r\n\r\n" + ex.Message;
                        }
                    }

                    if (_url != null)
                    {
                        // Display the OK window:
                        this.MainContainer.Child = new PageWhenConnected(_url, useLocalhost);

                        // Attempt to open the firewall:
                        // Note: we use the "Dispatcher" as a "DoEvents" way so that the window appears before any possible error message box related to Windows Firewall.
                        Dispatcher.BeginInvoke((Action)(() =>
                        {
                            try
                            {
                                _firewallRuleName = string.Format("CSHTML5 - Allow port {0}", this.GetPort());
                                Process.Start(new ProcessStartInfo
                                {
                                    FileName = "netsh",
                                    Arguments = string.Format("advfirewall firewall add rule name=\"{0}\" dir=in protocol=tcp localport={1} remoteip=localsubnet action=allow", _firewallRuleName, this.GetPort()),
                                    Verb = "runas",
                                    UseShellExecute = true,
                                    WindowStyle = ProcessWindowStyle.Normal
                                }).WaitForExit();
                            }
                            catch (Exception ex)
                            {
                                MessageBox.Show(
                                    string.Format(
                                        "We were unable to automatically configure the Windows Firewall for you.\r\n\r\nTo allow your mobile device to connect to this computer, please temporarily disable the Windows Firewall, or manually set the Windows Firewall to allow incoming connections to: {0}\r\n\r\nIf the problem persists, please report it to [email protected]\r\n\r\n------------------------------\r\nException details:\r\n" + ex.Message,
                                        _url));
                            }

                            //// Ensure access rights from other machines to the URL:
                            //if (_url != null)
                            //{
                            //    try
                            //    {
                            //        NetAclChecker.AddAddress(_url);
                            //    }
                            //    catch (Exception ex)
                            //    {
                            //        MessageBox.Show("Error while attempting to give access rights to the new web server URL: " + url + "\r\n\r\nException details:\r\n\r\n" + ex.Message);
                            //    }
                            //}
                        }));
                    }
                    else
                    {
                        if (!cancel)
                        {
                            MessageBox.Show(exceptionMessage ?? "Unable to start the web server. Please report this issue to [email protected]");
                            Quit();
                        }
                    }
                }
                else
                {
                    MessageBox.Show(exceptionMessage ?? "Unable to determine the machine IP address. Please report this issue to [email protected]");
                    Quit();
                }
            }
            else
            {
                MessageBox.Show("Invalid startup parameters. Please report this issue to [email protected]");
                Quit();
            }
        }
Пример #29
0
        //Start HTTP listener that servers the webapp
        private void StartHTTP(string Path, string IP, int Port)
        {
            serverHTTP = new SimpleHTTPServer(Path, IP, Port);

            Log("HTTP server started");
        }
Пример #30
0
 public void InitializeLocalHost()
 {
     myServer = new SimpleHTTPServer(ServerPath, 8080);
 }
Пример #31
0
 static void Main()
 {
     SimpleHTTPServer httpListener = new SimpleHTTPServer("C:\\Users\\dave_\\Desktop\\dist\\", 5555);
     MQTTBroker       mqttBroker   = new MQTTBroker(GlobalHost.ConnectionManager.GetHubContext <QXMonitorHub>().Clients);
 }
Пример #32
0
 public void StartServer()
 {
     myServer = new SimpleHTTPServer(GetSaveFolderPath, port, controller, bufferSize);
 }