0

How to or what's the best way to run (not call with curl) a REST API service using purely shell commands or scripts?

I would typically run APIs with Python using FastAPI, however, I was wondering if it is possible to do it in a less-Pythonic and more-Linux way.

Gino Mempin
  • 25,369
  • 29
  • 96
  • 135
average.everyman
  • 123
  • 1
  • 12
  • I'd suggest a "more Linux way" is to use python. Use the best tool for the job. – glenn jackman Dec 29 '21 at 14:22
  • 1
    Do you mean you want to **setup a web server** by using purely shell commands or scripts? – Gino Mempin Dec 30 '21 at 02:08
  • 1
    On SO, see [Minimal web server using netcat](https://stackoverflow.com/q/16640054/2745495). You could also see the related Q&A's over at [Unix & Linux](https://unix.stackexchange.com/help/on-topic), such as this [Simple command line HTTP server](https://unix.stackexchange.com/q/32182/370183) and this [Simple server that triggers script and responds](https://unix.stackexchange.com/q/139311/370183). I would say though that since you're comparing it with FastAPI, ... you might not get the same set of functionalities/features with purely shell commands/scripts. – Gino Mempin Dec 30 '21 at 02:14
  • thnx @GinoMempin that's exactly what I was looking for. I wanted to setup a web server (API) that, on being called, triggers another script and then sends an API response with the output of that other script. With Python I guess I would have to do it through calling a sub process, and so I wanted to it more with pure shell. – average.everyman Dec 30 '21 at 08:56

1 Answers1

0

Sampo is most likely what you're looking for.

Written in bash, it is a shell script API server you can run directly in your terminal or via container on Kubernetes.

It exposes endpoints which could trigger different actions, running a script among others.

Jarek
  • 782
  • 5
  • 16