meteor - creating proxy url with meteorjs -
i wondering how might achieve following using ironrouter in meteorjs:
app.route("/api/tts").get(function(req,res){ res.type('audio/mpeg'); var text = req.query.q; var request = require('request'); var url = "https://translate.google.pl/translate_tts?ie=utf-8&q=" + text + "&tl=en&total=1&idx=0&client=t&prev=input"; request.get(url).pipe(res); });
if have iron:router
installed already, can. need install request
using meteorhacks:npm
.
then write:
router.route("/api/tts", function () { // nodejs request object var req = this.request; // nodejs response object var res = this.response; res.type('audio/mpeg'); var text = req.query.q; var request = meteor.npmrequire('request'); var url = "https://translate.google.pl/translate_tts?ie=utf-8&q=" + text + "&tl=en&total=1&idx=0&client=t&prev=input"; request.get(url).pipe(res); }, { where: 'server' });
let me know if works.
Comments
Post a Comment