forked from helionyeah/helionce-node
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathserver.js
More file actions
30 lines (24 loc) · 1.09 KB
/
server.js
File metadata and controls
30 lines (24 loc) · 1.09 KB
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
var express = require('express'),
moment = require('moment'),
convert = require('./convert'),
port = process.env.PORT || 8080;
// App
var app = express();
app.set('views', __dirname + '/views');
app.set('view engine', 'jade');
app.use(express.static(__dirname));
app.get('/', function(req, res) {
res.render('index', { title: 'Environment Variables View', message: 'Environment Variables', environmentVariables: process.env });
});
app.get('/celciusToFahrenheit', function(req, res) {
var celciusTemperature = parseFloat(req.query.c);
var fahrenheitTemperature = convert.celciusToFahrenheit(celciusTemperature);
res.send(celciusTemperature + '℃ is ' + fahrenheitTemperature + '℉ to the nearest tenth.');
});
app.get('/fahrenheitToCelcius', function(req, res) {
var fahrenheitTemperature = parseFloat(req.query.f);
var celciusTemperature = convert.fahrenheitToCelcius(fahrenheitTemperature);
res.send(fahrenheitTemperature + '℉ is ' + celciusTemperature + '℃ to the nearest tenth.');
});
app.listen(parseInt(port, 10));
console.log('Running on http://localhost: ' + port);