-
Notifications
You must be signed in to change notification settings - Fork 0
/
server.js
49 lines (40 loc) · 1.69 KB
/
server.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
module.exports = {
startServer: function(){
const express = require('express')
const handlebars = require('express-handlebars')
const path = require('path')
const bodyParser = require('body-parser')
const app = express()
const tools = require('./conversor')
// CONFIG
app.engine('handlebars',handlebars({defaultLayout:'main'}))
app.set('view engine','handlebars')
app.use(bodyParser.json({limit: '50mb'}))
app.use(bodyParser.urlencoded({limit: '50mb', extended: true}))
app.use(express.static(path.join(__dirname,'public')))
// ROTAS
app.get('/',(req,res)=>{
res.render('./pages/index')
})
app.post('/check',(req,res)=>{
if(req.body.schema != '' && req.body.quantity != ''){
var result = tools.check(req.body.schema,req.body.quantity)
res.render('./pages/index',{schema:req.body.schema,shacl:result.shacl,resultado:result.text,log:result.log,time:result.time,runs:result.runs})
} else {
var result = ''
if(req.body.schema == ''){
result += 'JSON Schema not provided! '
}
if(req.body.quantity == ''){
result += 'No specification of how many runs!'
}
res.render('./pages/index',{schema:req.body.schema,resultado:result})
}
})
// PORT
const PORT = process.env.PORT || 8080
app.listen(PORT,()=>{
console.log(`Server running in localhost:${PORT}`)
})
}
}