This file contains hidden or 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
var http = require("http"); | |
var path = require("path"); | |
var fs = require("fs"); | |
var extensions = { | |
".html":"text/html", | |
".css":"text/css", | |
".js":"text/javascript", | |
".png":"image/png", | |
".gif":"image/gif", | |
".jpg":"image/jpeg", |
This file contains hidden or 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
var connect = require("connect"); | |
var server = require("serve-static"); | |
var router = require("connect-route"); | |
var app = connect(); | |
app.use(router(route)); | |
app.use(server(__dirname + '/public')); |
This file contains hidden or 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
var connect = require("connect"); | |
var server = require("serve-static"); | |
var router = require("connect-route"); | |
var io = require("socket.io").listen(1337); | |
var app = connect(); | |
app.use(router(route)); | |
app.use(server(__dirname + '/public')); |
This file contains hidden or 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
<html> | |
<body> | |
<h1>Socket.io Test!!! :)</h1> | |
<form id="myForm"> | |
<input id="firstname" type="text"> | |
<input id="lastname" type="text"> | |
<input id="submit" type="submit"> | |
</form> | |
<script src="http://localhost:1337/socket.io/socket.io.js"></script> | |
<script> |
This file contains hidden or 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
var connect = require("connect"); | |
var server = require("serve-static"); | |
var router = require("connect-route"); | |
var qs = require("querystring"); | |
var path = require("path"); | |
var fs = require("fs"); | |
var mustache = require("mustache"); | |
var app = connect(); |
This file contains hidden or 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> | |
<meta charset="utf-8"> | |
<title>Node.js template test with mustache</title> | |
</head> | |
<body> | |
<h1>Enter your information</h1> | |
<form action="/tmpl/:myTemplate.html" method="POST"> | |
<label>First Name: <input name="firstname" type="text" value="{{firstname}}"></label> |
This file contains hidden or 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
(function(){ | |
var words={}, | |
html = "", | |
writer = function(inx,ele){ | |
html += (inx > 0 ? "<h"+inx+">"+ele+"</h"+inx+">" : "<span>"+ele+"</span>"); | |
}; | |
document.body.textContent.split(" ") | |
.filter(function(ele){ return !/\d/.test(ele) && ele.length > 3 }) | |
.map(function(ele){ |
This file contains hidden or 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
var http = require("http"); | |
var log = require("./log"); | |
var cache = require("./cache"); | |
var getRequestTime = require("./request-time"); | |
var requestList = []; //request buffer | |
//register a Node.js http request then monitor the request | |
//monitor means to check if the request is in process, a duplicate or it finished | |
function registerRequest(url){ |
This file contains hidden or 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
var cache = require("./cache"); | |
function doRequest(url, httpRes){ | |
var data = cache.get(url); | |
if (data){ | |
httpRes.json(200, JSON.parse(data)); | |
} | |
return !!data; | |
} |
This file contains hidden or 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
var cache = require("./cache-service"); | |
var http = require("./http-monitor"); | |
var NOT_READY = { statusCode:202, data:"" }; | |
function doRequest(serviceID, httpReq, serviceResults){ | |
var httpRes = { //overrides httpRes.json() dispatches data without blocking the browser | |
json:function(statusCode, data){ | |
if (arguments.length === 1){ | |
data = statusCode; |