Create a Morse Code serverless FaaS function in Quick Basic!

Why?

Why would anyone sane code using such an old language?

Why not? - JM

After my quick dive into FaaS, I was thinking what would be the oldest language I've written with and how much time would it take me to wrap it up in a Docker image and drop in a FaaS function?

Less than an hour

You can check out the code here:
https://github.com/jmkhael/faas-qbasic-morse/

Building and deploying

Build the Docker image.

docker build . -t jmkhael/faas-qbasic-morse

Ship it to FaaS

Either via faas-cli

Build the FaaS cli first:

git clone https://github.com/alexellis/faas-cli
cd faas-cli/
go get -d -v
go build

Then use the cli to ship the newly built image:

./faas-cli -action=deploy \
   -image=jmkhael/faas-qbasic-morse \
   -name=morse \
   -handler="python handler.py" \
   -lang=python

Alternatively, ship with curl

You can always use curl to deploy the function to FaaS:

curl localhost:8080/system/functions -d '{
   "service": "morse",
   "image": "jmkhael/faas-qbasic-morse",
   "envProcess": "python handler.py",
   "network": "func_functions"
  }'

or if you are a UI portal kind of person, navigate to: http://localhost:8080

Test the Morse Code Serverless Function

Time to test our function, let's run it:

curl -X POST http://localhost:8080/function/morse -d "FaaS-inating!".

and see it answer in Morse:

  ..-. .- .- ...  .. -. .- - .. -. --.

morse-faas

Now you can talk Morse via QBasic/Faas!

(I've based most of my code shamelessly on the repo and adapted it to be able to drop in a QBasic FaaS function here - it was about going fast anyway)