-
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit e9cc3a5
Showing
6 changed files
with
1,068 additions
and
0 deletions.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
node_modules |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
var http = require('http'), | ||
fs = require('fs'), | ||
csv = require('csv'), | ||
connect = require('connect'), | ||
Router = require('browserver-router'); | ||
|
||
var router = Router({ | ||
'/upload' : function(req, res) { | ||
var json = {}, | ||
first = true; | ||
fs.readFile(req.files['csv'].path, function(err, content) { | ||
csv() | ||
.from('' + content) | ||
.on('record', function(row, index) { | ||
if (first) { | ||
json.headers = row; | ||
json.data = []; | ||
first = false; | ||
} else { | ||
json.data.push(row); | ||
} | ||
}).on('end', function() { | ||
res.writeHead(200, {'Content-Type': 'application/json'}); | ||
res.end(JSON.stringify(json)); | ||
}); | ||
}); | ||
} | ||
}); | ||
|
||
var app = connect() | ||
|
||
.use(connect.favicon()) | ||
.use(connect.static('public')) | ||
.use(connect.directory('public')) | ||
.use(connect.bodyParser()) | ||
.use(router); | ||
|
||
http.createServer(app).listen(1234); |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
{ | ||
"name": "csv-view", | ||
"version": "0.0.0", | ||
"description": "A very simple CSV viewer", | ||
"main": "index.js", | ||
"repository": "", | ||
"author": "Wes Todd", | ||
"license": "BSD", | ||
"dependencies": { | ||
"csv": "~0.3.0", | ||
"connect": "~2.7.6", | ||
"browserver-router": "~0.1.1" | ||
} | ||
} |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
<!DOCTYPE html> | ||
<!--[if lt IE 7]> <html class="no-js lt-ie9 lt-ie8 lt-ie7"> <![endif]--> | ||
<!--[if IE 7]> <html class="no-js lt-ie9 lt-ie8"> <![endif]--> | ||
<!--[if IE 8]> <html class="no-js lt-ie9"> <![endif]--> | ||
<!--[if gt IE 8]><!--> <html class="no-js"> <!--<![endif]--> | ||
<head> | ||
<meta charset="utf-8"> | ||
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1"> | ||
<title></title> | ||
<meta name="description" content=""> | ||
<meta name="viewport" content="width=device-width"> | ||
<link href='http://fonts.googleapis.com/css?family=Noto+Sans:400,700,400italic,700italic' rel='stylesheet' type='text/css'> | ||
<link rel="stylesheet" href="/main.css"> | ||
</head> | ||
<body> | ||
<h1>Gimme dat file! <small>Drag it over me</small></h1> | ||
<div id="container"></div> | ||
<div id="overlay"></div> | ||
<script src="/main.js"></script> | ||
</body> | ||
</html> |
Oops, something went wrong.