Thanks to visit codestin.com
Credit goes to github.com

Skip to content

mguptahub/nanoHttp

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

17 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

nanoHttp

nanoHttp is a lightweight HTTP server manager that allows you to run multiple HTTP server instances on different ports. It's designed to be simple to use while providing essential features for serving static files.

Features

  • Run multiple HTTP server instances on different ports
  • Configuration management at ~/.nanoHttp/config
  • Customizable instance settings:
    • Port number (default: 8080)
    • Web root folder
    • Directory listing (optional)
  • Instance management (add, delete, start, stop)
  • Process tracking with PID management
  • Enhanced display options:
    • Table format with status colors
    • Simple format for detailed view
  • Self-update capability
  • Simple CLI interface with comprehensive help system

Installation

Quick Install (Recommended)

curl -fsSL https://nanohttp.mguptahub.com/install.sh | bash

This will automatically detect your OS and architecture, download the appropriate binary, and install it to /usr/local/bin.

Manual Installation

If you prefer to install manually, you can download the binary directly:

Linux

# For AMD64
curl -L -o nanoHttp https://github.com/mguptahub/nanoHttp/releases/latest/download/nanoHttp-linux-amd64

# For ARM64
curl -L -o nanoHttp https://github.com/mguptahub/nanoHttp/releases/latest/download/nanoHttp-linux-arm64

# Make it executable
chmod +x nanoHttp

# Move to a directory in your PATH
sudo mv nanoHttp /usr/local/bin/

macOS

# For Intel (AMD64)
curl -L -o nanoHttp https://github.com/mguptahub/nanoHttp/releases/latest/download/nanoHttp-darwin-amd64

# For Apple Silicon (ARM64)
curl -L -o nanoHttp https://github.com/mguptahub/nanoHttp/releases/latest/download/nanoHttp-darwin-arm64

# Make it executable
chmod +x nanoHttp

# Move to a directory in your PATH
sudo mv nanoHttp /usr/local/bin/

Usage

nanoHttp provides a simple command-line interface. Use --help with any command to see detailed usage information:

# Show general help
nanoHttp --help

# Show help for specific commands
nanoHttp add --help
nanoHttp start --help
nanoHttp stop --help
nanoHttp delete --help
nanoHttp list --help
nanoHttp update --help
nanoHttp version --help

Adding a new instance

# Basic usage with required flags
nanoHttp add -name myserver -web-folder /path/to/files

# Full usage with all options
nanoHttp add -name myserver \
  -port 8080 \
  -web-folder /path/to/files \
  -allow-dir-listing

Managing instances

# Start an instance
nanoHttp start myserver

# Stop an instance
nanoHttp stop myserver

# Delete an instance
nanoHttp delete myserver

# List all instances (table format)
nanoHttp list

# List all instances with detailed view
nanoHttp list --simple

The list command provides two display formats:

  • Default table format: Compact view with color-coded status
  • Simple format (--simple): Detailed view showing full paths and information

System commands

# Check for updates
nanoHttp update

# Show version
nanoHttp version

Configuration

The configuration file is stored at ~/.nanoHttp/config in JSON format. Here's an example configuration:

{
  "instances": {
    "myserver": {
      "name": "myserver",
      "port": 8080,
      "web_folder": "/path/to/files",
      "allow_dir_listing": true,
      "is_running": false
    }
  }
}

Building from source

# Clone the repository
git clone https://github.com/mguptahub/nanoHttp.git
cd nanoHttp

# Build the binary
go build -o nanoHttp cmd/nanoHttp/main.go

Command-line Options

Add Command

  • -name (required): Instance name
  • -port (default: 8080): Port number
  • -web-folder (required): Web root folder
  • -allow-dir-listing (default: false): Allow directory listing

Other Commands

  • start <instance-name>: Start an instance
  • stop <instance-name>: Stop an instance
  • delete <instance-name>: Delete an instance
  • list: List all instances
  • update: Check for updates
  • version: Show version information

License

MIT License

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.