Skip to content

Instantly share code, notes, and snippets.

@heyAyushh
Last active November 22, 2018 21:49
Show Gist options
  • Save heyAyushh/dea570c4ad2d132282a3145e7253efbc to your computer and use it in GitHub Desktop.
Save heyAyushh/dea570c4ad2d132282a3145e7253efbc to your computer and use it in GitHub Desktop.
Azure function which responds with cowsay.
var cowsay = require('cowsay');
module.exports = async function (context, req) {
context.log('JavaScript HTTP trigger function processed a request.');
if (req.query.text || (req.body && req.body.text)) {
context.res = {
// status: 200, /* Defaults to 200 */
body: cowsay.say({
text : req.query.text || (req.body && req.body.text),
e : "oO",
T : "U "
})
};
}
else {
context.res = {
status: 400,
body: "Please pass a text on the query string or in the request body"
};
}
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment