webify - Turn functions and 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
Brigodier is a command parser & dispatcher, designed and developed for command lines such as for Discord bots or Minecraft chat commands. It is a complete port from Mojang's "brigadier" into Go.

brigodier Brigodier is a command parser & dispatcher, designed and developed to provide a simple and flexible command framework. It can be used in man

Dec 15, 2022
Turn .mp3 files in current directory to a podcast feed just one command.

dir2cast Turn .mp3 files in current directory to a podcast feed just one command. Then you can subscribe to it with your favorite podcast client, down

Jun 27, 2022
cTRL is a server for remote execution of pending tasks and commands in real time, supporting a queue with continuous thread limiting and throttling.

Документация на русском: https://github.com/eltaline/ctrl/blob/master/README-RUS.md cTRL is a server written in Go language that uses a modified versi

Mar 3, 2022
Command-line tool to load csv and excel (xlsx) files and run sql commands
Command-line tool to load csv and excel (xlsx) files and run sql commands

csv-sql supports loading and saving results as CSV and XLSX files with data processing with SQLite compatible sql commands including joins.

Nov 2, 2022
GC2 is a Command and Control application that allows an attacker to execute commands on the target machine using Google Sheet and exfiltrate data using Google Drive.
GC2 is a Command and Control application that allows an attacker to execute commands on the target machine using Google Sheet and exfiltrate data using Google Drive.

GC2 GC2 (Google Command and Control) is a Command and Control application that allows an attacker to execute commands on the target machine using Goog

Dec 13, 2022
A Go library and common interface for running local and remote commands

go-runcmd go-runcmd is a Go library and common interface for running local and remote commands providing the Runner interface which helps to abstract

Nov 25, 2021
Go-ipfs-cmds - Cmds offers tools for describing and calling commands both locally and remotely
Go-ipfs-cmds - Cmds offers tools for describing and calling commands both locally and remotely

Go-ipfs-cmds - Cmds offers tools for describing and calling commands both locally and remotely

Jan 18, 2022
Jan 3, 2023
Tool for shell commands execution, visualization and alerting. Configured with a simple YAML file.
Tool for shell commands execution, visualization and alerting. Configured with a simple YAML file.

Sampler. Visualization for any shell command. Sampler is a tool for shell commands execution, visualization and alerting. Configured with a simple YAM

Dec 28, 2022
Integrated console application library, using Go structs as commands, with menus, completions, hints, history, Vim mode, $EDITOR usage, and more ...
Integrated console application library, using Go structs as commands, with menus, completions, hints, history, Vim mode, $EDITOR usage, and more ...

Gonsole - Integrated Console Application library This package rests on a readline console library, (giving advanced completion, hint, input and histor

Nov 20, 2022
convert curl commands to Python, JavaScript, Go, PHP, R, Dart, Java, MATLAB, Rust, Elixir and more
convert curl commands to Python, JavaScript, Go, PHP, R, Dart, Java, MATLAB, Rust, Elixir and more

curlconverter curlconverter transpiles curl commands into programs in other programming languages. $ curlconverter --data "Hello, world!" example.com

Jan 2, 2023
Commands to Build and Run dockerized-go-service

Dockerized Go Service Commands to Build and Run dockerized-go-service Syntax: $ docker image build /path/to -t imageName:version -t imageName:revision

Oct 24, 2021
Testing local and remote shell commands in Go

Testing local and remote shell commands in Go. This is an (intentionally simplified) example of how unix shell commands can be unit-tested in Go. The

Nov 30, 2021
cTRL: a server for remote execution of pending tasks and commands in real time

Документация на русском: https://github.com/eltaline/ctrl/blob/master/README-RUS.md cTRL is a server written in Go language that uses a modified versi

Mar 3, 2022
Cobra CLI tool to generate applications and commands

Cobra Generator Cobra provides its own program that will create your application and add any commands you want. It's the easiest way to incorporate Co

Jan 3, 2023
A command line tool that builds and (re)starts your web application everytime you save a Go or template fileA command line tool that builds and (re)starts your web application everytime you save a Go or template file

# Fresh Fresh is a command line tool that builds and (re)starts your web application everytime you save a Go or template file. If the web framework yo

Nov 22, 2021
🧑‍💻📊 Show off your most used shell commands
🧑‍💻📊 Show off your most used shell commands

tsukae ??‍?? ?? Tsukae, 使え - means use in Japanese (so it refers to commands that you use) Built on top of termui and cobra Big shoutout to jokerj40 f

Dec 17, 2022
Go Library to Execute Commands Over SSH at Scale
Go Library to Execute Commands Over SSH at Scale

Go library to handle tens of thousands SSH connections and execute the command(s) with higher-level API for building network device / server automation.

Dec 9, 2022