Skip to content
Browse files

update examples to use the command

  • Loading branch information...
1 parent 5acb80f commit 6756545539687149edd3e1fc4031b1bfdef1405d @substack committed Aug 4, 2012
View
1 .npmignore
@@ -0,0 +1 @@
+example/**/bundle.js
View
2 example/get/index.html
@@ -1,9 +1,9 @@
<html>
<head>
<title>xhr</title>
- <script type="text/javascript" src="/browserify.js"></script>
</head>
<body>
<div id="result"></div>
+ <script type="text/javascript" src="/bundle.js"></script>
</body>
</html>
View
21 example/get/server.js
@@ -1,15 +1,12 @@
-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 http = require('http');
+var ecstatic = require('ecstatic')(__dirname);
+var server = http.createServer(function (req, res) {
+ if (req.url === '/beep') {
+ res.setHeader('content-type', 'text/plain');
+ res.end('boop');
+ }
+ else ecstatic(req, res);
});
-var browserify = require('browserify');
-var bundle = browserify(__dirname + '/main.js');
-app.use(bundle);
-
console.log('Listening on :8082');
-app.listen(8082);
+server.listen(8082);
View
2 example/headers/index.html
@@ -1,9 +1,9 @@
<html>
<head>
<title>xhr</title>
- <script type="text/javascript" src="/browserify.js"></script>
</head>
<body>
<div id="result"></div>
+ <script type="text/javascript" src="/bundle.js"></script>
</body>
</html>
View
27 example/headers/server.js
@@ -1,18 +1,15 @@
-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.setHeader('foo', 'bar');
- res.setHeader('bling', req.headers.bling + '-blong');
-
- res.end('boop');
+var http = require('http');
+var ecstatic = require('ecstatic')(__dirname);
+var server = http.createServer(function (req, res) {
+ if (req.url === '/beep') {
+ res.setHeader('content-type', 'text/plain');
+ res.setHeader('foo', 'bar');
+ res.setHeader('bling', req.headers.bling + '-blong');
+
+ res.end('boop');
+ }
+ else ecstatic(req, res);
});
-var browserify = require('browserify');
-var bundle = browserify(__dirname + '/main.js');
-app.use(bundle);
-
console.log('Listening on :8082');
-app.listen(8082);
+server.listen(8082);
View
2 example/post/index.html
@@ -1,9 +1,9 @@
<html>
<head>
<title>xhr</title>
- <script type="text/javascript" src="/browserify.js"></script>
</head>
<body>
<div id="result"></div>
+ <script type="text/javascript" src="/bundle.js"></script>
</body>
</html>
View
35 example/post/server.js
@@ -1,22 +1,19 @@
-var express = require('express');
-var app = express.createServer();
-app.use(express.static(__dirname));
-
-app.post('/plusone', function (req, res) {
- res.setHeader('content-type', 'text/plain');
-
- var s = '';
- req.on('data', function (buf) { s += buf.toString() });
-
- req.on('end', function () {
- var n = parseInt(s) + 1;
- res.end(n.toString());
- });
+var http = require('http');
+var ecstatic = require('ecstatic')(__dirname);
+var server = http.createServer(function (req, res) {
+ if (req.method === 'POST' && req.url === '/plusone') {
+ res.setHeader('content-type', 'text/plain');
+
+ var s = '';
+ req.on('data', function (buf) { s += buf.toString() });
+
+ req.on('end', function () {
+ var n = parseInt(s) + 1;
+ res.end(n.toString());
+ });
+ }
+ else ecstatic(req, res);
});
-var browserify = require('browserify');
-var bundle = browserify(__dirname + '/main.js');
-app.use(bundle);
-
console.log('Listening on :8082');
-app.listen(8082);
+server.listen(8082);
View
2 example/streaming/index.html
@@ -1,9 +1,9 @@
<html>
<head>
<title>xhr</title>
- <script type="text/javascript" src="/browserify.js"></script>
</head>
<body>
<div id="result"></div>
+ <script type="text/javascript" src="/bundle.js"></script>
</body>
</html>
View
39 example/streaming/server.js
@@ -1,24 +1,21 @@
-var express = require('express');
-var app = express.createServer();
-app.use(express.static(__dirname));
-
-app.get('/doom', function (req, res) {
- res.setHeader('content-type', 'multipart/octet-stream');
-
- res.write('d');
- var i = 0;
- var iv = setInterval(function () {
- res.write('o');
- if (i++ >= 10) {
- clearInterval(iv);
- res.end('m');
- }
- }, 500);
+var http = require('http');
+var ecstatic = require('ecstatic')(__dirname);
+var server = http.createServer(function (req, res) {
+ if (req.url === '/doom') {
+ res.setHeader('content-type', 'multipart/octet-stream');
+
+ res.write('d');
+ var i = 0;
+ var iv = setInterval(function () {
+ res.write('o');
+ if (i++ >= 10) {
+ clearInterval(iv);
+ res.end('m');
+ }
+ }, 500);
+ }
+ else ecstatic(req, res);
});
-var browserify = require('browserify');
-var bundle = browserify(__dirname + '/main.js');
-app.use(bundle);
-
console.log('Listening on :8082');
-app.listen(8082);
+server.listen(8082);

0 comments on commit 6756545

Please sign in to comment.
Something went wrong with that request. Please try again.