mirror of
https://github.com/tenrok/axios.git
synced 2026-06-20 20:00:40 +03:00
Updating examples
This commit is contained in:
+5
-5
@@ -2,8 +2,8 @@
|
|||||||
|
|
||||||
To run the examples:
|
To run the examples:
|
||||||
|
|
||||||
1. Clone this repo
|
1. `git clone git@github.com:mzabriskie/axios.git`
|
||||||
2. Run `npm install`
|
2. `npm install`
|
||||||
3. Run `grunt build`
|
3. `grunt build`
|
||||||
4. Run `npm run examples`
|
4. `npm run examples`
|
||||||
5. Open http://localhost:3000
|
5. [http://localhost:3000](http://localhost:3000)
|
||||||
|
|||||||
+26
-4
@@ -23,6 +23,31 @@ function listDirs(root) {
|
|||||||
return dirs;
|
return dirs;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function getIndexTemplate() {
|
||||||
|
var links = dirs.map(function (dir) {
|
||||||
|
var url = '/' + dir;
|
||||||
|
return '<li onclick="document.location=\'' + url + '\'"><a href="' + url + '">' + url + '</a></li>';
|
||||||
|
});
|
||||||
|
|
||||||
|
return (
|
||||||
|
'<!doctype html>' +
|
||||||
|
'<html>' +
|
||||||
|
'<head>' +
|
||||||
|
'<title>axios examples</title>' +
|
||||||
|
'<style>' +
|
||||||
|
'body {padding:25px;}' +
|
||||||
|
'ul {margin:0; padding:0; list-style:none;}' +
|
||||||
|
'li {padding:5px 10px;}' +
|
||||||
|
'li:hover {background:#eee; cursor:pointer;}' +
|
||||||
|
'a {text-decoration:none; color:#0080ff;}' +
|
||||||
|
'</style>' +
|
||||||
|
'<body>' +
|
||||||
|
'<ul>' +
|
||||||
|
links.join('') +
|
||||||
|
'</ul>'
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
function sendResponse(res, statusCode, body) {
|
function sendResponse(res, statusCode, body) {
|
||||||
res.writeHead(statusCode);
|
res.writeHead(statusCode);
|
||||||
res.write(body);
|
res.write(body);
|
||||||
@@ -72,10 +97,7 @@ server = http.createServer(function (req, res) {
|
|||||||
|
|
||||||
// Process /
|
// Process /
|
||||||
if (url === '/' || url === '/index.html') {
|
if (url === '/' || url === '/index.html') {
|
||||||
var links = dirs.map(function (dir) {
|
send200(res, getIndexTemplate());
|
||||||
return '<li><a href="/' + dir + '">' + dir + '</a></li>';
|
|
||||||
});
|
|
||||||
send200(res, '<!doctype html><html><body><ul>' + links.join('') + '</ul>');
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user