-
Notifications
You must be signed in to change notification settings - Fork 110
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
James Halliday
committed
Aug 20, 2011
1 parent
10760d6
commit 1831dbc
Showing
3 changed files
with
43 additions
and
0 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
<html> | ||
<head> | ||
<title>xhr</title> | ||
<script type="text/javascript" src="/browserify.js"></script> | ||
</head> | ||
<body> | ||
<div id="result"></div> | ||
</body> | ||
</html> |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
var http = require('http'); | ||
|
||
http.get({ path : '/beep' }, function (res) { | ||
var div = document.getElementById('result'); | ||
|
||
div.innerHTML += JSON.stringify(res.headers) + '<br>'; | ||
|
||
res.on('data', function (buf) { | ||
div.innerHTML += buf; | ||
}); | ||
|
||
res.on('end', function () { | ||
div.innerHTML += '!'; | ||
}); | ||
}); |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
var express = require('express'); | ||
var app = express.createServer(); | ||
app.use(express.static(__dirname)); | ||
|
||
app.get('/beep', function (req, res) { | ||
res.setHeader('content-type', 'text/plain'); | ||
res.end('boop'); | ||
}); | ||
|
||
var browserify = require('browserify'); | ||
var bundle = browserify({ | ||
entry : __dirname + '/main.js', | ||
require : { http : 'http-browserify' }, | ||
watch : true | ||
}); | ||
app.use(bundle); | ||
|
||
console.log('Listening on :8082'); | ||
app.listen(8082); |