Skip to content

Instantly share code, notes, and snippets.

@theacodes
Created September 6, 2014 18:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save theacodes/7854bcafc25c63494d52 to your computer and use it in GitHub Desktop.
Save theacodes/7854bcafc25c63494d52 to your computer and use it in GitHub Desktop.
Simple socket.io log viewer
<!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