https://github.com/spikehd/swerve
Speedy, no-fuss CLI webserver for testing/serving static files and directories.
https://github.com/spikehd/swerve
Last synced: 10 months ago
JSON representation
Speedy, no-fuss CLI webserver for testing/serving static files and directories.
- Host: GitHub
- URL: https://github.com/spikehd/swerve
- Owner: SpikeHD
- License: gpl-3.0
- Created: 2024-04-22T18:13:35.000Z (about 2 years ago)
- Default Branch: main
- Last Pushed: 2024-12-15T20:57:31.000Z (over 1 year ago)
- Last Synced: 2025-06-29T11:03:05.858Z (12 months ago)
- Language: Rust
- Homepage:
- Size: 195 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
Swerve
Speedy, no-fuss local webserver for testing/serving static files or directories.

# Features
* Multithreaded with a customizable thread pool
* Native ARM support
* Serve directories, webserver directory index style
* Test and serve static sites of all kinds (regular HTML, built React, etc.)
* Serve static sites in Docker
* Optional hot reloading
* Optional basic auth
* Glob patterns for including/excluding files
# Table of Contents
* [Installation](#installation)
* [Package Repositories](#package-repositories)
* [Manual Installation](#manual-installation)
* [Usage](#usage)
* [Usage in Docker](#usage-in-docker)
* [Building](#building)
* [Prerequisites](#prerequisites)
* [Steps](#steps)
* [TODO](#todo)
* [Contributions](#contributions)
# Installation
## Package Repositories
### Windows
* WinGet
```sh
winget install SpikeHD.swerve
```
> [!NOTE]
> Maintaining `swerve` somewhere else? Feel free to add it here!
## Manual Installation
You can obtain binaries through [releases](https://github.com/SpikeHD/swerve/releases/), [GitHub Actions](https://github.com/SpikeHD/swerve/actions?query=workflow%3Abuild) artifacts, or by building from source!
### Windows
```powershell
# Run the install script
Invoke-WebRequest -Uri "https://raw.githubusercontent.com/SpikeHD/swerve/refs/heads/main/install.ps1" -OutFile "$env:TEMP\install.ps1"; PowerShell -ExecutionPolicy Bypass -File "$env:TEMP\install.ps1"
# You can uninstall by deleting C:\Program Files\Swerve
del C:\Program Files\Swerve
```
### Linux
```shell
# Run the install script
curl -fsSL https://raw.githubusercontent.com/SpikeHD/swerve/refs/heads/main/install.sh | sudo bash
# You can uninstall by removing the binary from /usr/local/bin
rm /usr/local/bin/swerve
```
### macOS
```shell
# Run the install script
curl -fsSL https://raw.githubusercontent.com/SpikeHD/swerve/refs/heads/main/install.sh | sudo bash
# You can uninstall by removing the binary from /usr/local/bin
rm /usr/local/bin/swerve
```
# Usage
```shell
# Show help
swerve -h
# Serve the current directory
swerve
# Serve a specific directory
swerve path/to/directory
# Specify port
swerve -p 8080
# Enable hot reloading. This creates a websocket on port 8087.
swerve -H 8087
# Set basic auth credentials
swerve --basic-auth username:password
# Include files using a glob pattern
swerve -i *.html -i *.css -i *.js
# Exclude files using a glob pattern
swerve -e *.txt -e *.md
# Expose to the internet
swerve -p 8080 --bind 0.0.0.0
```
## Usage in Docker
```dockerfile
FROM ubuntu:latest
RUN echo "
Hello World
" > ./index.html
RUN apt update && apt install -y curl
RUN curl -fsSL https://raw.githubusercontent.com/SpikeHD/swerve/refs/heads/main/install.sh | bash
EXPOSE 8080
CMD ["swerve", "--port", "8080", "--bind", "0.0.0.0", "-r"]
```
You can access this by running the following:
```sh
docker build . --tag swerve-test
docker run -p 8080:8080 swerve-test
```
# Building
## Prerequisites
* [Rust](https://www.rust-lang.org/tools/install)
## Steps
1. Clone the repository
```shell
git clone https://github.com/SpikeHD/swerve.git
```
2. `cd` into the repository
```shell
cd swerve
```
3. Build the project
```shell
cargo build --release
```
The binary will be in `target/release/`.
# TODO
* [x] Include/exclude files/folders/globs
* [x] Embedded HTML/CSS for displaying directories
* [x] Optional hot-reloading
* [x] Multithreading
* [x] More details in directory listings (modified date, size, etc.)
* [x] Basic auth
# Contributions
Issues, PRs, etc. are all welcome!