Skip to content

Instantly share code, notes, and snippets.

@weird-ego
Last active July 30, 2020 14:13
Show Gist options
  • Save weird-ego/608ba451cc12674807cde99793b62bf6 to your computer and use it in GitHub Desktop.
Save weird-ego/608ba451cc12674807cde99793b62bf6 to your computer and use it in GitHub Desktop.
behold GLORIOUS emergence of QMAAS (quick math as a service)
FROM ubuntu:bionic
RUN apt-get -y update \
&& apt-get install -y curl \
&& curl -sL https://deb.nodesource.com/setup_14.x | bash \
&& apt-get install -y nodejs
RUN npm install -g express-generator \
&& express isoddeven \
&& cd isoddeven/ \
&& npm install && npm install is-odd is-even express
RUN echo 'const express = require("express"); \n\
const isOdd = require("is-odd"); \n\
const isEven = require("is-even"); \n\
const app = express() \n\
app.get("/oddp/:num", (req, res) => { \n\
res.send(isOdd(req.params.num)); \n\
}) \n\
app.get("/evenp/:num", (req, res) => { \n\
res.send(isEven(req.params.num)); \n\
}) \n\
module.exports = app;' > /isoddeven/app.js
CMD cd /isoddeven && ./bin/www
docker build -t isoddenev .
docker run -p 3000:3000 isoddenev:latest
curl http://127.0.0.1:3000/oddp/{-1, 0, 1,2,3,4,5,6,7,8,9}
curl http://127.0.0.1:3000/evenp/{-1, 0, 1,2,3,4,5,6,7,8,9}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment