-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathserver.js
More file actions
34 lines (28 loc) · 731 Bytes
/
Copy pathserver.js
File metadata and controls
34 lines (28 loc) · 731 Bytes
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
var express = require('express');
var app = express();
app.get('/favicon.ico', function(req, res) {
res.sendStatus(200);
});
app.get('/:input', (req, res)=>{
var input = req.params.input;
var times = {unix:null,
natural:null}
var parsed = Date.parse( input );
console.log( "input " + input);
if ( !isNaN(parsed) )
{
times.natural = input;
times.unix = parsed;
} else {
var date = new Date( Number(input) );
times.natural = date.toDateString();
times.unix = input
}
res.send( times );
});
app.listen(process.env.PORT, function(){
console.log('server listening on ' + process.env.PORT );
});
/*
https://fcc-api-danjool.c9users.io/
*/