Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

Add express app to serve files #1

Merged
merged 1 commit into from

2 participants

@oayandosu
Collaborator

No description provided.

@tonyjcamp tonyjcamp merged commit 361d842 into tonyjcamp:master
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Apr 3, 2012
  1. @oayandosu
This page is out of date. Refresh to see the latest.
Showing with 40 additions and 11 deletions.
  1. +21 −0 app.js
  2. +8 −0 package.json
  3. +11 −11 getUserMedia.html → public/index.html
View
21 app.js
@@ -0,0 +1,21 @@
+
+/**
+ * Module dependencies.
+ */
+
+var express = require('express');
+
+// shorthand server
+var app = express.createServer();
+
+// config public directory
+app.use(express.static(__dirname + '/public'));
+
+// Routes
+
+app.get('/', function(request, response) {
+ response.render('index');
+});
+
+app.listen(3000);
+console.log("Express server listening on port %d in %s mode", app.address().port, app.settings.env);
View
8 package.json
@@ -0,0 +1,8 @@
+{
+ "name": "application-name",
+ "version": "0.0.1",
+ "private": true,
+ "dependencies": {
+ "express": "2.5.8"
+ }
+}
View
22 getUserMedia.html → public/index.html
@@ -34,7 +34,7 @@
<!-- NEEDS THE DAMN WIDTH AND HEIGHT SET ON THE ELEMENT -->
<canvas id="snapshot" width="640" height="480" class="hidden">
-
+
</canvas>
<button id="take">Take Picture</button>
@@ -83,11 +83,11 @@
var FILTER_VALS = {};
var filters = ['grayscale', 'sepia', 'blur', 'brightness', 'contrast', 'hue-rotate', 'hue-rotate2', 'hue-rotate3', 'saturate', 'invert', 'reset'];
-
+
var addEvents = function ( lis, filter ) {
lis.addEventListener('click', function() {
// document.querySelector('canvas').classList.add(filter);
-
+
if ( this.classList[0] === 'reset' ) {
reset();
} else {
@@ -127,9 +127,9 @@
VIDEO_WIDTH, VIDEO_HEIGHT,
take = doc.querySelector('#take'),
computeSize = function(supportsObjectFit){
- // user agents that don't support object-fit
- // will display the video with a different
- // aspect ratio.
+ // user agents that don't support object-fit
+ // will display the video with a different
+ // aspect ratio.
if (supportsObjectFit == true){
VIDEO_WIDTH = 640;
VIDEO_HEIGHT = 480;
@@ -160,17 +160,17 @@
var snapshot = document.getElementById('snapshot'),
img = snapshot.toDataURL( "image/png" );
- // hide canvas, show final image
+ // hide canvas, show final image
document.write('<img src = ' + img + ' />');
};
take.addEventListener('click', snap, false);
-
+
window.addEventListener('DOMContentLoaded', function() {
if ( hasGetUserMedia() ) {
-
+
if (navigator.getUserMedia) {
navigator.getUserMedia({'video': true}, function( stream ) {
@@ -180,7 +180,7 @@
}, errorCallback);
}
-
+
if (navigator.webkitGetUserMedia) {
// doesn't work using file:///Uset/path...
navigator.webkitGetUserMedia('video', function( stream ){
@@ -194,7 +194,7 @@
} else {
console.log('Native web camera streaming (getUserMedia) is not supported in this browser.');
-
+
}
}, false);
Something went wrong with that request. Please try again.