Skip to content

Instantly share code, notes, and snippets.

@omarayad1
Created June 11, 2016 18:35
Show Gist options
  • Save omarayad1/768a9d7c00c42b03062049cf18064e08 to your computer and use it in GitHub Desktop.
Save omarayad1/768a9d7c00c42b03062049cf18064e08 to your computer and use it in GitHub Desktop.
from requests import get,post
from json import loads
PORT = "5000"
HOST = "localhost"
get_request_content = get('http://'+HOST+':'+PORT+'/hello').content
print "response data: ", loads(get_request_content)['content']
post_request_content = post('http://'+HOST+':'+PORT+'/incr', data={"num":548}).content
print "response data: ", loads(post_request_content)['content']
var express = require('express');
var bodyParser = require('body-parser');
var app = express();
app.use(bodyParser.json());
app.use(bodyParser.urlencoded({
extended: true
}));
app.get('/hello', function (req, res) {
res.json({'content':'Hello World!'});
});
app.post('/incr', function (req, res) {
res.json({'content':parseInt(req.body.num)+1});
});
app.listen(5000, function () {
console.log('Application is Running');
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment