-
Notifications
You must be signed in to change notification settings - Fork 0
/
controller.js.orig
60 lines (52 loc) · 1.46 KB
/
controller.js.orig
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
var models = require('./models');
var exec = require('child_process').exec;
var cmd = "date";
var date = function() {
return exec(cmd,
function(error, stdout, stderr) {
console.log('stdout: '+(stdout||'none'));
console.log('stderr: '+(stderr||'none'));
if(error !== null) {
console.log('exec error: '+error);
}
app.set('out', stdout);
});
};
exports.bind = function(app) {
<<<<<<< HEAD
app.get('/', function(request, response) {
date();
response.send(app.get('out'));
=======
app.get('/', function(req, res) {
var result = date();
res.send(result.toString());
>>>>>>> f9547a6f662e05c4244ba3b6a1f1c0eff6ffafde
});
app.get('/test', function(req, res) {
res.send('Hello Wanderful2 !!!!');
});
app.get('/test2', function(req, res) {
res.render('index.ejs', {locals:{ problem: "abc" }});
});
app.get('/submit', function(req, res) {
res.render('submit.ejs', {locals:{ }});
});
app.post('/submit', function(req, res) {
var submit = new models.Submit({
name: req.body.name,
code: req.body.code,
date: new Date()
});
submit.save(function(err) {
if (err) { console.log('failed to save Submit'); }
res.redirect('/');
});
});
app.get('/submits', function(req, res) {
models.Submit.find({}, function(err, docs) {
if (err) { console.log('failed to find Submit.'); }
res.render('submits.ejs', {locals:{ submits: docs }});
});
});
};