Skip to content
This repository has been archived by the owner on Jan 29, 2024. It is now read-only.

Commit

Permalink
fix(demo): fix server routes + add index page
Browse files Browse the repository at this point in the history
Fixes error in server routes definition.
Also adds an index page to show available demos, because demo files have complicated names
  • Loading branch information
DWand committed Jan 24, 2014
1 parent 23e6331 commit eb0a2dc
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 1 deletion.
21 changes: 21 additions & 0 deletions demo/index.htm
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>Demo</title>
</head>
<body>
<h1>Go to demo:</h1>
<ul>
<li><a href="ex1_basic_usage.htm">Basic usage example</a></li>
<li><a href="ex2_remember_language_(cookies).htm">How to remember language (coockies)</a></li>
<li><a href="ex3_remember_language_(local_storage).htm">How to remember language (local storage)</a></li>
<li><a href="ex4_set_a_storage_key.htm">How to set a storage key</a></li>
<li><a href="ex5_set_a_storage_prefix.htm">How to set a storage prefix</a></li>
<li><a href="ex6_namespace_support.htm">How to use namespaces</a></li>
<li><a href="ex7_load_static_files.htm">How to use $translateStaticFilesLoader</a></li>
<li><a href="ex8_lazy_load_files_without_autoupload.htm">How to use predefined translation tables with loaders</a></li>
<li><a href="ex9_load_dynamic_files.htm">How to use $translateUrlLoader</a></li>
</ul>
</body>
</html>
19 changes: 18 additions & 1 deletion demo/server_routes.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,21 @@
module.exports = function (app, dir) {
var url = require('url'), fs = require('fs');

app.get('/demo/', function(req, res) {
function answer(code, data) {
res.writeHead(code,{
'Content-Type':'text/html;charset=utf-8'
});
res.end(data);
};

var _get = url.parse(req.url, true).query;
fs.readFile('./demo/index.htm', function(err, data) {
if (err) answer(404, '');
else answer(200, data);
});
});

app.get('/demo/get_lang', function (req, res) {
function answer(code, data) {
res.writeHead(code,{
Expand All @@ -16,10 +31,12 @@ module.exports = function (app, dir) {
if (err) answer(404, '');
else answer(200, data);
});

});

// Example
app.get('/this-is-an-express-server', function (req, res) {
res.send(200);
});

};

0 comments on commit eb0a2dc

Please sign in to comment.