Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1388)

Side by Side Diff: chrome/test/data/third_party/spaceport/server/index.js

Issue 10134041: Add test data for spaceport benchmark. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « chrome/test/data/third_party/spaceport/results/raw/1330415380941_10.0.1.187.json ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 var express = require('express');
2 var app = express.createServer();
3
4 app.configure(function () {
5 app.use(express.static(__dirname + '/../'));
6 app.use(express.logger());
7 app.use(app.router);
8 });
9
10 app.configure('development', function(){
11 app.use(express.errorHandler({
12 dumpExceptions: true,
13 showStack: true
14 }));
15 });
16
17 app.configure('production', function(){
18 app.use(express.errorHandler());
19 });
20
21 var UPLOAD_DIRECTORY = __dirname + '/uploads';
22
23 function saveUpload(data) {
24 var filename = UPLOAD_DIRECTORY + '/' + (data.date + '_' + data.ip).replace( /[^A-Za-z0-9_.-]/g, '_') + '.json';
25 require('fs').writeFile(filename, JSON.stringify(data) + '\n', 'utf8');
26 }
27
28 app.post('/results', function (req, res) {
29 var date = Date.now();
30
31 var jsonData = '';
32 req.on('data', function (data) {
33 jsonData += data.toString('utf8');
34 });
35
36 req.on('end', function () {
37 var userData = JSON.parse(jsonData);
38 saveUpload({
39 date: date,
40 ip: req.connection.remoteAddress,
41 userData: userData
42 });
43 res.end();
44 });
45
46 req.resume();
47 });
48
49 app.listen(3002);
50 console.log('Listening on :3002');
OLDNEW
« no previous file with comments | « chrome/test/data/third_party/spaceport/results/raw/1330415380941_10.0.1.187.json ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698