Skip to content

Instantly share code, notes, and snippets.

@seanhess
Last active December 30, 2015 22:39
Show Gist options
  • Save seanhess/7895618 to your computer and use it in GitHub Desktop.
Save seanhess/7895618 to your computer and use it in GitHub Desktop.
HTTP and Express Example
// var http = require('http');
// http.createServer(function(req, res) {
// // console.log("REQUEST", req)
// var body = ""
// req.on('data', function(data) {
// body = body + data.toString()
// })
// req.on('end', function() {
// console.log("COMPLETE", JSON.parse(body))
// })
// res.writeHead(200, {'Content-Type': 'text/plain'});
// res.end('Hello World\n');
// }).listen(1337);
// console.log('Server running at http://127.0.0.1:1337/');
var express = require('express')
var app = express()
app.use(express.bodyParser())
app.post("/henry/:id", function(req, res) {
console.log("REQ", req.body)
res.send(200)
})
app.listen(1337)
.controller("AdminToolsControl", function($scope, $http:ng.IHttpService){
$scope.result = ""
$scope.migrateCreations = function() {
$scope.result = "Loading..."
$http.post("/api/creations/migrate", "").then(function(rs) {
$scope.result = rs.data
}, function(data) {
$scope.result = data
});
}
$scope.sendStuff = function() {
var creation = {
name: "hello"
}
$http.post("/stuff", creation).then(function(rs) {
console.log(rs.data)
})
}
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment