Created
June 11, 2016 18:35
-
-
Save omarayad1/768a9d7c00c42b03062049cf18064e08 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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'] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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