Skip to content

feat: replace Flask with Rust HTTP server (#45) - #48

Merged
zackees merged 1 commit into
mainfrom
feat/replace-flask-with-rust-server
Apr 12, 2026
Merged

zackees merged 1 commit into
mainfrom
feat/replace-flask-with-rust-server

Conversation

@zackees

@zackees zackees commented Apr 12, 2026

Copy link
Copy Markdown
Member

Summary

  • Rust CLI now orchestrates the full compile+serve+watch lifecycle, eliminating Flask as a runtime dependency
  • compile_and_serve() in main.rs starts the Axum HTTP server, opens the browser, calls Python --just-compile, and enters a file-watching loop using watcher.rs + keyboard.rs
  • Removes Flask, flask-cors, and cryptography from pyproject.toml (net -111 lines of dependencies)
  • Deletes server_flask.py (226 lines), debug_routes.py (47 lines), and their test

What changed

Rust

  • main.rs: New compile_and_serve() function + routing in main() for the normal compilation flow
  • server.rs: Added CORS layer via tower-http
  • build.rs, watcher.rs, keyboard.rs: Removed #![allow(dead_code)] — now wired in

Python

  • compile_native.py: Stripped to compile-only (no server spawn, no watch loop)
  • open_browser.py: spawn_http_server() now launches fastled --serve-dir as a subprocess
  • app.py: --serve-dir path returns error pointing to Rust CLI
  • pyproject.toml: Removed Flask, flask-cors, cryptography

Tests

  • Deleted test_debug_routes.py (debug routes deferred to follow-up)
  • Updated integration tests from HTTPS to HTTP (localhost is a secure context)

Design decisions

  • HTTP-only: localhost is a secure context in all browsers — HTTPS/TLS deferred
  • Debug routes deferred: /dwarfsource and /debug/source-roots require porting DebugSymbolResolver to Rust — follow-up PR
  • build-status.json as IPC: Rust writes status, loading page polls it

Test plan

  • cargo test -p fastled-cli — 55 tests pass
  • bash test — 119 Python tests pass
  • bash lint — all checks pass (cargo fmt, clippy, ruff, black, isort, pyright)
  • CI passes

Rust CLI now orchestrates the full compile+serve+watch lifecycle,
eliminating Flask, flask-cors, and cryptography as runtime dependencies.

Rust changes:
- main.rs: add compile_and_serve() — starts Axum HTTP server, opens
  browser, calls Python --just-compile, enters watch loop with
  watcher.rs + keyboard.rs
- server.rs: add CORS support via tower-http
- Wire watcher.rs, build.rs, keyboard.rs (remove dead_code annotations)

Python changes:
- Delete server_flask.py, debug_routes.py
- Simplify compile_native.py to compile-only (no server/watch)
- open_browser.py: spawn_http_server() now launches Rust CLI --serve-dir
- Remove Flask, flask-cors, cryptography from pyproject.toml

Tests:
- Delete test_debug_routes.py (debug routes deferred)
- Update integration tests for HTTP-only (localhost is secure context)
@zackees
zackees merged commit 3ddb99b into main Apr 12, 2026
25 checks passed
@zackees
zackees deleted the feat/replace-flask-with-rust-server branch April 12, 2026 13:05
zackees added a commit that referenced this pull request Apr 12, 2026
- Delete MicrophoneHttpsIntegrationTest class (HTTPS dropped in PR #48)
- Keep MicrophoneDemoValidationTest for micdemo.html content validation
- Remove #39 tracking references from skip markers
- Add test_http_server.py: HTTP smoke test using the Rust CLI binary
- Fix pre-existing pyright errors (playwright import suppressions)
- Fix pre-existing black formatting in playwright module
zackees added a commit that referenced this pull request Apr 12, 2026
- Delete MicrophoneHttpsIntegrationTest class (HTTPS dropped in PR #48)
- Keep MicrophoneDemoValidationTest for micdemo.html content validation
- Remove #39 tracking references from skip markers
- Add test_http_server.py: HTTP smoke test using the Rust CLI binary
- Fix pre-existing pyright errors (playwright import suppressions)
- Fix pre-existing black formatting in playwright module
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant