swerve SpikeHD
winget install --id=SpikeHD.swerve -e
Speedy, no-fuss serving of directories on a localhost webserver.
Primary Purpose
Swerve is a command-line interface (CLI) webserver designed to provide a speedy and hassle-free solution for serving directories on a localhost web server. It enables users to quickly test static files and directories with ease.
Key Features
- Multithreaded architecture with a customizable thread pool for efficient handling of multiple requests.
- Native ARM support, ensuring compatibility with modern hardware.
- Ability to serve directories in a webserver-style directory index format.
- Testing and serving static sites of all types, including regular HTML, React-built sites, and more.
- Integration with Docker for containerized environments.
- Optional hot reloading for seamless updates without restarting the server.
- Support for basic authentication to secure access to served content.
Audience & Benefit
Ideal for developers and testers who need a fast and reliable way to serve static files or directories locally. Swerve provides a no-fuss solution that allows users to focus on their work without complicated setup or configuration. It can be installed via winget, ensuring easy deployment across supported platforms.
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
Package Repositories
Windows
- WinGet
winget install SpikeHD.swerve
> [!NOTE]
> Maintaining swerve
somewhere else? Feel free to add it here!
Manual Installation
You can obtain binaries through releases, GitHub Actions artifacts, or by building from source!
Windows
# 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
# 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
# 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
# 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
FROM ubuntu:latest
RUN echo "<h1>Hello World</h1>" > ./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:
docker build . --tag swerve-test
docker run -p 8080:8080 swerve-test
Building
Prerequisites
Steps
- Clone the repository
git clone https://github.com/SpikeHD/swerve.git
cd
into the repository
cd swerve
- Build the project
cargo build --release
The binary will be in target/release/
.
TODO
- Include/exclude files/folders/globs
- Embedded HTML/CSS for displaying directories
- Optional hot-reloading
- Multithreading
- More details in directory listings (modified date, size, etc.)
- Basic auth
Contributions
Issues, PRs, etc. are all welcome!