Created
September 6, 2014 18:39
-
-
Save theacodes/7854bcafc25c63494d52 to your computer and use it in GitHub Desktop.
Simple socket.io log viewer
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
<!DOCTYPE html> | |
<html> | |
<head> | |
<script src="//ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script> | |
<script src="/static/socket.io.js"></script> | |
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.0.1/angular.min.js"></script> | |
<script> | |
angular.module('app', []) | |
.controller('logs', function($scope){ | |
var socket = io.connect('/logs'); | |
$scope.logs = []; | |
socket.on('log', function(data) { | |
$scope.$apply(function(){ | |
$scope.logs.append(data); | |
}); | |
}); | |
}); | |
</script> | |
</head> | |
<body ng-app="app" ng-controller="logs"> | |
<div class="container"> | |
<div class="row" ng-repeat="log in logs"> | |
{{log.line}} | |
</div> | |
</div> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment