Last active
November 22, 2018 21:49
-
-
Save heyAyushh/dea570c4ad2d132282a3145e7253efbc to your computer and use it in GitHub Desktop.
Azure function which responds with cowsay.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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