1
0
mirror of https://github.com/arduino-libraries/ArduinoHttpClient.git synced 2025-07-05 04:01:10 +03:00

Initial port of examples from RestClient

This commit is contained in:
Sandeep Mistry
2016-06-21 14:10:43 -04:00
parent 94a8723420
commit fc3e6c6fe7
16 changed files with 710 additions and 0 deletions

View File

@ -0,0 +1,42 @@
/*
Express.js GET/POST example
Shows how handle GET, POST, PUT, DELETE
in Express.js 4.0
created 14 Feb 2016
by Tom Igoe
*/
var express = require('express'); // include express.js
var app = express(); // a local instance of it
var bodyParser = require('body-parser'); // include body-parser
// you need a body parser:
app.use(bodyParser.urlencoded({extended: false})); // for application/x-www-form-urlencoded
// this runs after the server successfully starts:
function serverStart() {
var port = server.address().port;
console.log('Server listening on port '+ port);
}
// this is the POST handler:
app.all('/*', function (request, response) {
console.log('Got a ' + request.method + ' request');
// the parameters of a GET request are passed in
// request.body. Pass that to formatResponse()
// for formatting:
console.log(request.headers);
if (request.method == 'GET') {
console.log(request.query);
} else {
console.log(request.body);
}
// send the response:
response.send('OK');
response.end();
});
// start the server:
var server = app.listen(8080, serverStart);

View File

@ -0,0 +1,16 @@
{
"name": "node_test_server",
"version": "0.0.1",
"author": {
"name":"Tom Igoe"
},
"dependencies": {
"express": ">=4.0.0",
"body-parser" : ">=1.11.0",
"multer" : "*"
},
"engines": {
"node": "0.10.x",
"npm": "1.3.x"
}
}