mirror of
https://github.com/tenrok/axios.git
synced 2026-05-15 11:59:42 +03:00
Updating examples
This commit is contained in:
+5
-5
@@ -2,8 +2,8 @@
|
||||
|
||||
To run the examples:
|
||||
|
||||
1. Clone this repo
|
||||
2. Run `npm install`
|
||||
3. Run `grunt build`
|
||||
4. Run `npm run examples`
|
||||
5. Open http://localhost:3000
|
||||
1. `git clone git@github.com:mzabriskie/axios.git`
|
||||
2. `npm install`
|
||||
3. `grunt build`
|
||||
4. `npm run examples`
|
||||
5. [http://localhost:3000](http://localhost:3000)
|
||||
|
||||
+26
-4
@@ -23,6 +23,31 @@ function listDirs(root) {
|
||||
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) {
|
||||
res.writeHead(statusCode);
|
||||
res.write(body);
|
||||
@@ -72,10 +97,7 @@ server = http.createServer(function (req, res) {
|
||||
|
||||
// Process /
|
||||
if (url === '/' || url === '/index.html') {
|
||||
var links = dirs.map(function (dir) {
|
||||
return '<li><a href="/' + dir + '">' + dir + '</a></li>';
|
||||
});
|
||||
send200(res, '<!doctype html><html><body><ul>' + links.join('') + '</ul>');
|
||||
send200(res, getIndexTemplate());
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user