All Projects → syntaqx → Serve

syntaqx / Serve

Licence: mit
a static http server anywhere you need one.

Programming Languages

go
31211 projects - #10 most used programming language

Projects that are alternatives of or similar to Serve

Simple Console
Add an elegant command-line interface to any page
Stars: ✭ 107 (-54.08%)
Mutual labels:  cli, command
Typin
Declarative framework for interactive CLI applications
Stars: ✭ 126 (-45.92%)
Mutual labels:  cli, command
Sywac
🚫 🐭 Asynchronous, single package CLI framework for Node
Stars: ✭ 109 (-53.22%)
Mutual labels:  cli, command
Executor
Watch for file changes and then execute command. Very nice for test driven development.
Stars: ✭ 14 (-93.99%)
Mutual labels:  cli, command
You Dont Need Gui
Stop relying on GUI; CLI **ROCKS**
Stars: ✭ 4,766 (+1945.49%)
Mutual labels:  cli, command
Flybook
✈️ FlyBook is a simple utility to generate static website such as gh-pages, manual of you projects
Stars: ✭ 76 (-67.38%)
Mutual labels:  cli, static-site
Fenix
A simple and visual static web server with collaboration features.
Stars: ✭ 1,559 (+569.1%)
Mutual labels:  static-site, http-server
Arg
Simple argument parsing
Stars: ✭ 897 (+284.98%)
Mutual labels:  cli, command
Cbox
convert any python function to unix-style command
Stars: ✭ 154 (-33.91%)
Mutual labels:  cli, command
Hiboot
hiboot is a high performance web and cli application framework with dependency injection support
Stars: ✭ 150 (-35.62%)
Mutual labels:  cli, command
Vercel
Develop. Preview. Ship.
Stars: ✭ 8,015 (+3339.91%)
Mutual labels:  cli, command
Webpack Command
[DEPRECATED] Lightweight, modular, and opinionated webpack CLI that provides a superior experience
Stars: ✭ 218 (-6.44%)
Mutual labels:  cli, command
Serve
Static file serving and directory listing
Stars: ✭ 7,444 (+3094.85%)
Mutual labels:  cli, command
Gql
Very simple CLI for many GraphQL schemas in the cloud. Provides autocompletion for GraphQL queries
Stars: ✭ 101 (-56.65%)
Mutual labels:  cli, command
Aruba
Test command-line applications with Cucumber-Ruby, RSpec or Minitest. The most up to date documentation can be found on Cucumber.Pro (https://app.cucumber.pro/projects/aruba)
Stars: ✭ 900 (+286.27%)
Mutual labels:  cli, command
Scaffold Static
Scaffolding utility for vanilla-js
Stars: ✭ 111 (-52.36%)
Mutual labels:  cli, static-site
Binserve
A blazingly fast static web server with routing, templating, and security in a single binary you can set up with zero code. ⚡️🦀
Stars: ✭ 401 (+72.1%)
Mutual labels:  static-site, http-server
Cobra
A Commander for modern Go CLI interactions
Stars: ✭ 24,437 (+10387.98%)
Mutual labels:  cli, command
Simplecli
Command Line Interface Library for Arduino
Stars: ✭ 135 (-42.06%)
Mutual labels:  cli, command
Miniserve
🌟 For when you really just want to serve some files over HTTP right now!
Stars: ✭ 2,894 (+1142.06%)
Mutual labels:  cli, http-server

serve is a static http server anywhere you need one.

GoDoc Build Status codecov Go Report Card Mentioned in Awesome Go

GitHub Release Docker Cloud Automated build Docker Cloud Build Status Docker Pulls

Deploy to Heroku

TL;DR

It's basically python -m SimpleHTTPServer 8080 written in Go, because who can remember that many letters?

Features

  • HTTPS (TLS)
  • CORS support
  • Request logging
  • net/http compatible

Installation

serve can be installed in a handful of ways:

Homebrew on macOS

If you are using Homebrew on macOS, you can install serve with the following command:

brew install syntaqx/tap/serve

Docker

The official syntaqx/serve image is available on Docker Hub.

To get started, try hosting a directory from your docker host:

docker run -v .:/var/www:ro -d syntaqx/serve

Alternatively, a simple Dockerfile can be used to generate a new image that includes the necessary content:

FROM syntaqx/serve
COPY . /var/www

Place this in the same directory as your content, then build and run the container:

docker build -t some-content-serve .
docker run --name some-serve -d some-content-serve

Exposing an external port

docker run --name some-serve -d -p 8080:8080 some-content-serve

Then you can navigate to http://localhost:8080/ or http://host-ip:8080/ in your browser.

Using environment variables for configuration

Currently, serve only supports using the PORT environment variable for setting the listening port. All other configurations are available as CLI flags.

In future releases, most configurations will be settable from both the CLI flag as well as a compatible environment variable, aligning with the expectations of a 12factor app. But, that will require a fair amount of work before the functionality is made available.

Here's an example using docker-compose.yml to configure serve to use HTTPS:

version: '3'
services:
  web:
    image: syntaqx/serve
    volumes:
      - ./static:/var/www
      - ./fixtures:/etc/ssl
    environment:
      - PORT=1234
    ports:
      - 1234
    command: serve -ssl -cert=/etc/ssl/cert.pem -key=/etc/ssl/key.pem -dir=/var/www

The project repository provides an example docker-compose that implements a variety of common use-cases for serve. Feel free to use those to help you get started.

Download the binary

Quickly download install the latest release:

curl -sfL https://install.goreleaser.com/github.com/syntaqx/serve.sh | sh

Or manually download the latest release binary for your system and architecture and install it into your $PATH.

From source

To build from source, check out the instructions on getting started with development.

Usage

serve [options] [path]

[path] defaults to . (relative path to the current directory)

Then simply open your browser to http://localhost:8080 to view your server.

Options

The following configuration options are available:

  • --host host address to bind to (defaults to 0.0.0.0)
  • --port listening port (defaults to 8080)
  • --ssl enable https (defaults to false)
  • --cert path to the ssl cert file (defaults to cert.pem)
  • --key path to the ssl key file (defaults to key.pem)
  • --dir directory path to serve (defaults to ., also configurable by arg[0])
  • --users path to users file (defaults to users.dat); file should contain lines of username:password in plain text

Development

To develop serve or interact with its source code in any meaningful way, be sure you have the following installed:

Prerequisites

Tooling

Note: While the tooling isn't explicitly required in order to build and run the project, it's for everyone's benefit that you leverage it.

Install

You can download and install the project from GitHub by simply running:

git clone [email protected]:syntaqx/serve.git && cd $(basename $_ .git)
make install

This will install serve into your $GOPATH/bin directory, which assuming is properly appended to your $PATH, can now be used:

$ serve version
serve version v0.0.6-8-g5074d63 windows/amd64

Using serve manually

Besides running serve using the provided binary, you can also embed a serve.FileServer into your own Go program:

package main

import (
    "log"
    "net/http"

    "github.com/syntaqx/serve"
)

func main() {
    fs := serve.NewFileServer()
    log.Fatal(http.ListenAndServe(":8080", fs))
}

License

serve is open source software released under the MIT license.

As with all Docker images, these likely also contain other software which may be under other licenses (such as Bash, etc from the base distribution, along with any direct or indirect dependencies of the primary software being contained).

As for any pre-built image usage, it is the image user's responsibility to ensure that any use of this image complies with any relevant licenses for all software contained within.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].