-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathserver.js
More file actions
48 lines (38 loc) · 1.27 KB
/
Copy pathserver.js
File metadata and controls
48 lines (38 loc) · 1.27 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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
const express = require('express');
const config = require('./config');
const bodyParser = require('body-parser');
const hbs = require('hbs');
const homeRenderer = require('./renderers/home');
const imageFetcher = require('./renderers/imageFetcher');
const classUpdater = require('./renderers/classUpdater');
const labelServer = require('./renderers/labelServer');
const app = express();
app.use(bodyParser.json());
app.use(bodyParser.urlencoded({extended: true}));
app.use(express.static(__dirname+'/static'));
app.set('view engine', 'hbs');
hbs.registerPartials(__dirname + '/views/partials');
hbs.registerHelper('receiveObj', (obj) => {
return JSON.stringify(obj);
})
app.get('/',(req,res) => {
homeRenderer.render(req,res);
});
app.get('/:tiffName',(req,res) => {
res.render('annotation.hbs',{
tiffName:req.params.tiffName
});
});
app.get('/:tiffName/images',(req,res) => {
imageFetcher.fetch(req,res);
});
app.get('/:tiffName/labels',(req,res) => {
labelServer.serve(req,res);
})
app.post('/:tiffName/update',(req,res) => {
//TODO- After getting the pairNumber and selectedClass values, update the database accordingly
classUpdater.update(req,res);
});
app.listen(config.PORT, () => {
console.log(`Listening at PORT: ${config.PORT}`);
});