Turn shell commands into web services

webify

Turn functions and commands into web services

Build Status Go Report Card MIT License

For a real world example, see turning a Python function into a web service.

Overview

webify is a very basic CGI server which forwards all requests to a single script. A design goal is to be as zero-config as possible.

webify invokes your script and writes the request body to your process' stdin. Stdout is then passed back to the client as the HTTP response body.

If your script returns a non-zero exit code, the HTTP response status code will be 500.

Installation

webify is available from the project's releases page.

On macOS, it can also be installed via MacPorts:

sudo port install webify

Usage

# Make a web service out of `wc` to count the characters in the request body.
$ webify wc -c
2020/08/25 12:42:32 listening on :8080, proxying to wc -c

...

$ curl -d 'This is a really long sentence' http://localhost:8080
30

Official Docker image

The official Docker image is beefsack/webify.

It can be configured using the following environment variables:

  • ADDR - the address to listen on inside the container, defaults to :80
  • SCRIPT - the command to execute, defaults to /script

Mounting script and running official image

$ docker run -it --rm -p 8080:80 -v /path/to/my/script:/script beefsack/webify:latest
2020/08/25 04:27:46 listening on :80, proxying to /script

...

$ curl -d 'Some data' http://localhost:8080

Building a new image using official image as base

Create a Dockerfile like the following:

FROM beefsack/webify:latest
COPY myscript /script

Contributing

Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.

Please make sure to update tests as appropriate.

License

MIT

Owner
Michael Alexander
Programmer from Canberra, Australia, currently working for Technology 360 Group. Passionate about Rust, Linux, and FOSS.
Michael Alexander
Comments
  • Passing variable into webified bash script

    Passing variable into webified bash script

    I cannot seem to be able to make the following minimal example run:

    cat <<EOF > demo.sh
    #!/bin/sh
    
    VAR="\$(< /dev/stdin)"
    echo \$VAR
    EOF
    
    sudo chmod +x demo.sh
    docker run -it --rm -p 8080:80 -v $(realpath demo.sh):/script beefsack/webify:latest
    

    and then:

    curl http://localhost:8080 -d $(date '+%Y-%m-%d')
    

    Am I doing something wrong? Expected output is the current date. Actual is a blank line. I would like to help with extending webify if this is a missing feature and I find the time.

  • Webify service for encrypting files

    Webify service for encrypting files

    I would like to webify a service for encrypting files (oversimplification, but let's just say they are short yaml files to be encrypted). The way I envision interacting with webify is to curl it with:

    • the key to be used in encryption (a separate file).
    • the yaml to be encrypted.

    Something like:

    curl \
      -F "key=@/home/me/key" \
      -F "input_yaml=@/home/me/input.yaml" \
      localhost:8080
    

    How do I store the key and input.yaml files on the backend side to start the process?

  • webify manager

    webify manager

    Hi, I'm searching for a solution to replace a project i use : https://github.com/eoli3n/shellcast It's a nodejs app, that I didn't maintain, but which works well.

    It is kind of webify but with those features:

    • Multiple instances in a declarative yaml file
    • a Single webserver which map commands to routes. http://localhost/command1 http://localhost/command2
    • dynamic commands with php args -> shell args
    • password protection for each webservices
    • plain output (curl) and JS realtime shell output
    • realtime highlighter by word|line in JS output

    I'm still looking for a tool to replace it. I need same features but i can skip the js realtime shell output part. If i don't find anything, i will maybe upgrade shellcast and fix vulnerabilities.

  • Serving of simple text not updating in Docker, cached text displayed instead

    Serving of simple text not updating in Docker, cached text displayed instead

    Using webify in docker, I'm seeing cached values for simple text:

    script.sh:

    #!/bin/sh
    
    echo foo
    
    docker run -d --rm -p 8080:80 -v  $(realpath script.sh):/script beefsack/webify
    

    If I change foo to bar, curl http://localhost:8080 still displays the old value.

    This only occurs in Docker, if I run webify on baremetal, the updated value bar is displayed.

  • Feature/Enhancement Request: Cloud Deploy

    Feature/Enhancement Request: Cloud Deploy

    Add support for runtimes:

    webify [--runtime=docker|azure|aws|gcloud|localhost] <command>

    Running docker run -it -v script.sh:/script ... does not work unless:

    1. Host is linux (binding a single file, not folder with -v does not seem to work on macOS)
    2. Docker engine is running on the same machine where the docker run command is being executed (often not the case; I am on macOS and use docker-machine).

    The idea is for this to be a stepping stone to building docker images that can run as Azure Functions or other "serverless" runtimes.

    Also keeps webify pure in that --runtime can default to "localhost" (i.e. just run webify locally as now).

    Runtime Docker

    1. build docker image with script copied
    2. either echo "image name" or docker run -it --rm <image> ?

    Runtime Azure

    No idea yet, but https://github.com/Azure-Samples/functions-custom-handlers/tree/master/go might be a starting point

  • MacPorts Installation Instructions Added

    MacPorts Installation Instructions Added

    Hi there. As of https://github.com/macports/macports-ports/pull/8418, webify has been added to MacPorts! (A summary page can be found here)

    I thought it might be useful to update the installation instructions to reflect this. Thanks.

  • [sharing]a ruby implement of webify

    [sharing]a ruby implement of webify

    I like the idea that webify can quickly turning a cli command into a http service. I wrote a ruby script to implement it with 6 lines of codes using pure ruby. here is the gist: https://gist.github.com/rainchen/3a91ef481e78ad38d51c91da0ab40e7f have fun~

  • Realistic example and documentation update

    Realistic example and documentation update

    The examples in the README aren't useful. Implement a more realistic minimal example and update documentation to clarify what webify should and shouldn't be used for.

  • Don't log error for client connection close

    Don't log error for client connection close

    When the client closes the connection, we see errors in the server stderr such as:

    2020/08/29 21:09:56 error writing response body: write tcp [::1]:8080->[::1]:50044: write: broken pipe
    

    These aren't useful errors and should be suppressed. These errors have the value syscall.EPIPE.

painless task queue manager for shell commands with an intuitive cli interface (execute shell commands in distributed cloud-native queue manager).

EXEQ DOCS STILL IN PROGRESS. Execute shell commands in queues via cli or http interface. Features Simple intuitive tiny cli app. Modular queue backend

Dec 14, 2022
Turn a heterogeneous pile of text docs into a single web page with good search.
Turn a heterogeneous pile of text docs into a single web page with good search.

Codex Codex turns an unstructured pile of heterogeneous documents into a single interactive web document. Your input documents maybe in markdown, TeX,

Jan 2, 2022
Amazon Web Services (AWS) providerAmazon Web Services (AWS) provider

Amazon Web Services (AWS) provider The Amazon Web Services (AWS) resource provider for Pulumi lets you use AWS resources in your cloud programs. To us

Nov 10, 2021
OliveTin is a web interface for running Linux shell commands.
OliveTin is a web interface for running Linux shell commands.

OliveTin OliveTin is a web interface for running Linux shell commands. Some example use cases; Give controlled access to run shell commands to less te

Dec 30, 2022
OliveTin is a web interface for running Linux shell commands.
OliveTin is a web interface for running Linux shell commands.

OliveTin OliveTin is a web interface for running Linux shell commands. Some example use cases; Give controlled access to run shell commands to less te

Dec 29, 2022
A code generator that turns plain old Go services into RPC-enabled (micro)services with robust HTTP APIs.

Frodo Frodo is a code generator and runtime library that helps you write RPC-enabled (micro) services and APIs. It parses the interfaces/structs/comme

Dec 16, 2022
A code generator that turns plain old Go services into RPC-enabled (micro)services with robust HTTP APIs.

Frodo is a code generator and runtime library that helps you write RPC-enabled (micro) services and APIs.

Dec 16, 2022
Turn Nginx logs into Prometheus metrics

Nginx log parser and Prometheus exporter This service parses incoming syslog messages from Nginx sent over UDP and converts them into Prometheus metri

Dec 13, 2022
Turn any program that uses STDIN/STDOUT into a WebSocket server. Like inetd, but for WebSockets.

websocketd websocketd is a small command-line tool that will wrap an existing command-line interface program, and allow it to be accessed via a WebSoc

Dec 31, 2022
turn a directory into a GUI, slash example of VNC-based GUI

dirgui @rsnous on Jan 11, 2021: "idea: filesystem<->GUI adapter, where a directory turns into a form, executable files inside that directory turn into

May 3, 2022
yml2dot - Turn YAML into beautiful Graph
yml2dot - Turn YAML into beautiful Graph

yml2dot - Turn YAML into beautiful Graph Use Cases Visualize your YAML files as Graph Generate additional info from your source code

Dec 30, 2022
Turn asterisk-indented text lines into mind maps
Turn asterisk-indented text lines into mind maps

Crumbs Turn asterisk-indented text lines into mind maps. Organize your notes in a hierarchical tree structure, using a simple text editor. an asterisk

Jan 8, 2023
A CLI to turn Go's benchmark output into pictures

benchdraw benchdraw allows you to make easy to read picture plots from data in Go's benchmark format, implemented in pure Go. Benchdraw does not try t

Nov 28, 2022
GoPrisma - A Go wrapper for prisma to turn databases into GraphQL APIs using Go.

GoPrisma - a Go wrapper for the Prisma Engines What's this? Introspect a database and use it as a GraphQL API using Go. Supported Databases: SQLite Po

Dec 20, 2022
Turn any key/value index into a high-performance two-dimensional spatial index
Turn any key/value index into a high-performance two-dimensional spatial index

modular-spatial-index For the demo that this animated gif was generated from

Mar 6, 2022
Turn a Spotify playlist into a YouTube playlist
Turn a Spotify playlist into a YouTube playlist

spotlist Turn a Spotify playlist into a YouTube playlist How to use: Download latest version from Releases. (Quick Links: Mac/Windows) Run it Enter Sp

Sep 8, 2022
A plugin that turn hashicorp vault into blockchain wallet.
A plugin that turn hashicorp vault into blockchain wallet.

dq-vault - Hashicorp vault BTC/ETH plugin This vault plugin stores a user's mnemonic inside vault in an encrypted manner. The plugin uses this stored

Dec 7, 2022
Turn a grid of frames (stored in a single image) into a video file
Turn a grid of frames (stored in a single image) into a video file

reel2vid Convert a video that is encoded into one large image as many images sid

Dec 19, 2021
Totem - A Go library that can turn a single gRPC stream into bidirectional unary gRPC servers

Totem is a Go library that can turn a single gRPC stream into bidirectional unar

Jan 6, 2023
Turn your Go program(s) into an appliance running on the Raspberry Pi 3 or 4 (or on amd64 PCs!)

Overview gokrazy packs your Go application(s) into an SD card image for the Raspberry Pi 3 or 4 which — aside from the Linux kernel and proprietary Ra

Jan 3, 2023