| Crates.io | webserve |
| lib.rs | webserve |
| version | 0.1.0 |
| created_at | 2025-04-25 04:42:50.876334+00 |
| updated_at | 2025-04-25 04:42:50.876334+00 |
| description | A lightweight web server |
| homepage | |
| repository | |
| max_upload_size | |
| id | 1648515 |
| size | 55,413 |
A blazing-fast static file and SPA Web server written in Rust, powered by warp. Supports live reload, SPA fallback, and directory serving โ like npm serve, but compiled and production-ready.
-d ./dist)--spa)--watch)-h, -p)git clone https://github.com/your-username/webserve
cd webserve
cargo build --release
The executable will be located in target/release/webserve.
You can also install it globally (requires Rust):
cargo install --path .
webserve [OPTIONS]
| Flag | Description | Default |
|---|---|---|
-d, --dir |
Directory to serve files from | Current directory |
-p, --port |
Port to listen on | 8080 |
-h, --host |
Host/IP to bind | 127.0.0.1 |
--spa |
Enable SPA fallback (404 โ index.html) | disabled |
-w, --watch |
Enable file watching + auto-reload | disabled |
Serve a Vite/React app from ./dist, with SPA fallback and live reload:
webserve -d ./dist --spa --watch
When --watch is used, index.html is automatically injected with:
<script>
const socket = new WebSocket(`ws://${location.host}/reload`);
socket.onmessage = () => location.reload();
</script>
webserve/
โโโ src/
โ โโโ main.rs # Web server logic
โโโ Cargo.toml # Dependencies
โโโ README.md
MIT ยฉ Mark Wayne Menorca