Rapidly run a single-binary static HTTP server

Get the latest version number

MINISERVE_VERSION=$(curl -s https://api.github.com/repos/svenstaro/miniserve/releases/latest | grep -Po '"tag_name": "v\K[0-9.]+')

# Download the binary
curl -L -o miniserve "https://github.com/svenstaro/miniserve/releases/latest/download/miniserve-${MINISERVE_VERSION}-x86_64-unknown-linux-musl"

# Make it executable
chmod +x miniserve

# Move it to a directory in your PATH (optional)
sudo mv miniserve /usr/local/bin/

# Run it (serving current directory)
miniserve .

.

#!/bin/bash

# Set the directory to the first argument, default to current dir if not provided
DIR="${1:-.}"

# List files with size, last modified, and MD5 hash, sorted by modified time (newest first)
find "$DIR" -type f -printf "%T@ %p\n" | sort -nr | while read -r line; do
    timestamp=${line%% *}
    filepath=${line#* }
    mod_time=$(date -d "@$timestamp" "+%Y-%m-%d %H:%M:%S")
    size=$(stat --printf="%s" "$filepath")
    hash=$(md5sum "$filepath" | awk '{print $1}')
    printf "%-10s  %-20s  %-40s  %s\n" "$size" "$mod_time" "$hash" "$filepath"
done

# Serve the directory using miniserve on port 8000
miniserve "$DIR" --port 8000