Last active
December 30, 2015 22:39
-
-
Save seanhess/7895618 to your computer and use it in GitHub Desktop.
HTTP and Express Example
This file contains hidden or 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 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) |
This file contains hidden or 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
.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