(&mut self)
| 493 | } |
| 494 | |
| 495 | fn start_web_server(&mut self) -> Result<(), Box<dyn std::error::Error>> { |
| 496 | self.update_progress(0, 5, "Building for web..."); |
| 497 | |
| 498 | // Run web build script |
| 499 | let status = Command::new("sh") |
| 500 | .args(["scripts/build-web.sh"]) |
| 501 | .status()?; |
| 502 | |
| 503 | if !status.success() { |
| 504 | return Err("Web build failed".into()); |
| 505 | } |
| 506 | |
| 507 | self.update_progress(2, 5, "Starting web server..."); |
| 508 | |
| 509 | let config = self.load_project_config()?; |
| 510 | let port = config.web_config.port.unwrap_or(8080); |
| 511 | |
| 512 | // Start Python HTTP server |
| 513 | let server = Command::new("python3") |
| 514 | .args(["-m", "http.server", &port.to_string()]) |
| 515 | .current_dir("www") |
| 516 | .spawn()?; |
| 517 | |
| 518 | let mut window = SimulatorWindow::new(Platform::Web); |
| 519 | window.set_process(server); |
| 520 | self.simulator_windows.push(window); |
| 521 | |
| 522 | // Open browser |
| 523 | self.open_default_browser(port)?; |
| 524 | |
| 525 | self.update_progress(5, 5, "Web server ready!"); |
| 526 | Ok(()) |
| 527 | } |
| 528 | |
| 529 | fn open_browser(&self, browser: &str, port: u16) -> Result<(), Box<dyn std::error::Error>> { |
| 530 | let url = format!("http://localhost:{}", port); |
no test coverage detected