/GoWeb

GoLang | Make Any Shell Command as a Web API

Primary LanguageGo

Go Web

Make Any Shell Command as a Web API with Golang

Clients invoke the web API by sending HTTP GET and POST requests. Clients can also send in additional flags and arguments to be passed into the command/script wrapped within the web API. Result of the command/script execution is sent back to the client as a plain text payload.

Running

As an example, assume you need to expose the "timedatectl" command as a web API. You can simply run the tool as follows:

./GoWeb -p 8080 -b "timedatectl"

Now, the clients can invoke the API by sending an HTTP request to http://0.0.0.0:8080

You can also use this tool to expose custom shell scripts and other command-line programs. For example, if you have a Python script foo.py which you wish to expose as a web API, all you have to do is:

./GoWeb -p 8080 -b "python3 Mio.py"

Last words