https://github.com/marcuwynu23/webserve
A blazing-fast static file and SPA Web server
https://github.com/marcuwynu23/webserve
Last synced: 17 days ago
JSON representation
A blazing-fast static file and SPA Web server
- Host: GitHub
- URL: https://github.com/marcuwynu23/webserve
- Owner: marcuwynu23
- Created: 2025-04-11T05:36:32.000Z (6 months ago)
- Default Branch: main
- Last Pushed: 2025-04-25T01:58:51.000Z (6 months ago)
- Last Synced: 2025-04-25T02:54:46.289Z (6 months ago)
- Language: Rust
- Size: 14.6 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
webserve
![]()
![]()
![]()
![]()
A blazing-fast static file and SPA Web server written in **Rust**, powered by [`warp`](https://crates.io/crates/warp). Supports **live reload**, SPA fallback, and directory serving โ like `npm serve`, but compiled and production-ready.
---
## ๐ Features
- โ Serve any directory (`-d ./dist`)
- โ SPA fallback support (`--spa`)
- โ File watching with automatic browser reload (`--watch`)
- โ Configurable host and port (`-h`, `-p`)
- โ Built with Rust + Tokio for high performance---
## ๐ฆ Installation
```bash
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):
```bash
cargo install --path .
```---
## ๐ Usage
```bash
webserve [OPTIONS]
```### 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 |---
## ๐งช Example
Serve a Vite/React app from `./dist`, with SPA fallback and live reload:
```bash
webserve -d ./dist --spa --watch
```---
## ๐ป Injected Reload Script
When `--watch` is used, `index.html` is automatically injected with:
```html
const socket = new WebSocket(`ws://${location.host}/reload`);
socket.onmessage = () => location.reload();```
---
## ๐ Project Structure
```
webserve/
โโโ src/
โ โโโ main.rs # Web server logic
โโโ Cargo.toml # Dependencies
โโโ README.md
```---
## ๐ License
MIT ยฉ Mark Wayne Menorca