Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Node Proxy to forward commands to Yun
//replace {myport} with any port number and {mytoken} with any URL-friendly string.
var request = require('request');
const express = require('express')
const app = express()
app.get('/', (req, res) => {
if(req.query.token != '{mytoken}')
res.send('Invalid Token');
//bridge wants /arduino/command/ int/int for some reason
res.send('ok'); //respond first, otherwise it might time out
request('http://robotarmarduino.local/arduino/' + req.query.command + '/1/1', function (error, response, html) {
if (!error && response.statusCode == 200) {
console.log('command sent: ' + req.query.command);
console.log('response:' + html);
console.log('error: ', error, response, html);
app.listen({myport}, () => console.log('Proxy listening on port {myport}'))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.