Skip to content

Instantly share code, notes, and snippets.

@leosilvadev
Created March 9, 2016 23:46
Show Gist options
  • Save leosilvadev/c2ff16dd4f59d14ca695 to your computer and use it in GitHub Desktop.
Save leosilvadev/c2ff16dd4f59d14ca695 to your computer and use it in GitHub Desktop.
var express = require('express');
var app = express();
app.get('/add/:v1/:v2', function(request, response){
var v1 = parseFloat(request.params.v1);
var v2 = parseFloat(request.params.v2);
response.json({resultado: v1+v2});
});
app.get('/sub/:v1/:v2', function(request, response){
var v1 = parseFloat(request.params.v1);
var v2 = parseFloat(request.params.v2);
response.json({resultado: v1-v2});
});
app.get('/mult/:v1/:v2', function(request, response){
var v1 = parseFloat(request.params.v1);
var v2 = parseFloat(request.params.v2);
response.json({resultado: v1*v2});
});
app.get('/div/:v1/:v2', function(request, response){
var v1 = parseFloat(request.params.v1);
var v2 = parseFloat(request.params.v2);
response.json({resultado: v1/v2});
});
app.listen(8000, function(){
console.log('App online...');
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment