-
Notifications
You must be signed in to change notification settings - Fork 7
/
router.js
107 lines (93 loc) · 3.33 KB
/
router.js
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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
const express = require('express')
const textController = require('./controllers/text')
const visionController = require('./controllers/clarifai')
const router = express.Router()
router.get('/', function (req, res) {
res.render('index', {
title: 'Cognimates, Home'
});
});
router.get('/home', function (req, res) {
res.render('index', {
title: 'Cognimates, Home'
});
});
//begin text routes
router.get('/text_home', (req, res) => {
res.render('models/text/text_classifiers', {
title: 'Cognimates, Train a text model, Home'
})
})
router.get('/text/train', (req, res) => {
res.render('models/text/text_classifiers', {
title: 'Cognimates, Train a text model'
})
})
//routes for text api calls
router.post('/nlc/classifier', textController.createClassifier)
router.get('/nlc/classifier', textController.getClassifierInformation)
router.delete('/nlc/classifier', textController.deleteClassifier)
router.post('/nlc/createClass', textController.createClass)
router.delete('/nlc/removeClass', textController.removeClass)
router.post('/nlc/classify', textController.classifyText)
router.post('/nlc/addExamples', textController.addExamples)
router.post('/nlc/untrain', textController.untrain)
router.post('/nlc/trainAll', textController.trainAll)
router.get('/nlc/extension/:read/:write/:username/:model', (req, res) => {
var read_api = req.params.read;
var write_api = req.params.write;
var username = req.params.username;
var classifier_id = req.params.model;
res.contentType('application/javascript');
res.charset = 'UTF-8';
res.render('models/text/extension', {
read_api: read_api,
write_api: write_api,
username: username,
classifier_id: classifier_id,
layout: false
});
});
//begin vision routes
router.get('/vision_home', (req, res) => {
res.render('models/vision/vision_classifiers', {
title: 'Cognimates, Train a vision model, Home',
CLARIFAI_KEY: process.env.CLARIFAI_API_KEY
})
})
//vision api calls
// Temporarily commenting out vision routes to focus on text classification
// router.get('/vision/classifiers', visionController.getClassifiers)
// router.post('/vision/classifier', visionController.createClassifier)
// router.get('/vision/classifier', visionController.getClassifierInformation)
// router.delete('/vision/classifier', visionController.deleteClassifier)
// router.post('/vision/classify', visionController.classifyImages)
// router.post('/vision/classifyURLImage', visionController.classifyURLImage)
// router.post('/vision/updateClassifier', visionController.updateClassifier)
router.get("/vision/extension/:modelid", (req, res) => {
var model_id = req.params.modelid;
res.contentType('application/javascript');
res.charset = 'UTF-8';
res.render('models/vision/extension', {
CLARIFAI_KEY: process.env.CLARIFAI_API_KEY,
MODEL_ID: model_id,
layout: false
});
});
//begin doodle routes
router.get('/doodle', (req, res) => {
res.render('models/doodle/doodle', {
title: 'Cognimates, Doodle Model',
layout: 'doodle'
})
})
//begin visualizer routes
router.get('/visualizer', (req, res) => {
res.render('models/visualizer/index', {
title: 'Cognimates, Neural Network Visualizer',
layout: false
});
})
//health check
router.get('/health', textController.health);
module.exports = router