Skip to content
/ swerve Public

Speedy, no-fuss CLI webserver for testing/serving static files and directories.

License

Notifications You must be signed in to change notification settings

SpikeHD/swerve

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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 "<html><body><h1>Hello World</h1></body></html>" > ./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

  1. Clone the repository
git clone https://github.com/SpikeHD/swerve.git
  1. cd into the repository
cd swerve
  1. 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!

About

Speedy, no-fuss CLI webserver for testing/serving static files and directories.

Resources

License

Stars

Watchers

Forks

Packages

No packages published