File: examples/save_cam_captures/node.js/view.js

Recommend this page to a friend!
  Classes of Juan Chaves   JE5   examples/save_cam_captures/node.js/view.js   Download  
File: examples/save_cam_captures/node.js/view.js
Role: Example script
Content type: text/plain
Description: Example script
Class: JE5
jQuery plugin to generate canvas, audio and video
Author: By
Last change: Change data
Add play node example save_cam_captures
Date: 1 year ago
Size: 1,444 bytes


Class file image Download
var mysql = require('mysql'); var express = require('express'); var path = require('path'); var bodyParser = require('body-parser'); var app = express(); app.use(bodyParser.urlencoded({ extended: true })); app.use(express.static(path.join(__dirname, 'public'))); app.get('/view', function(req, res) { var connection = mysql.createConnection({ host : 'localhost', user : 'youruser', password : 'yourpass', database : 'yourdb' }); connection.connect(); var queryString = "SELECT * FROM `streaming` WHERE ID = 1"; connection.query(queryString, function(err, dates) { if (err) { console.log(err); } else { var array_imgs = dates[0].rec; res.send('<!DOCTYPE html>' +'<html>' +'<head>' +'<script src=""></script>' +'<title>View captures images db whith "Media capture"</title>' +'<meta charset="utf8">' +'</head>' +'<body>' +'<table>' +'<tr>' +'<td><h1>View captures images db whith "Media capture"</h1></td>' +'</tr>' +'</table>' +'<div id="output"></div>' +'<script>' +'var array_imgs = new Array('+array_imgs.substr(1)+');' +'for(a = 0; a < array_imgs.length; a++) {' +'$(\'#output\').append(\'<img src="\'+array_imgs[a]+\'" />\');' +'}' +'</script>' +'</body>' +'</html>' ); connection.end(); } }); }); console.log('server start'); app.listen(8001);