-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
54 lines (45 loc) · 1.22 KB
/
index.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
//import express and axois
const express=require("express")
const axios=require("axios")
const app=express()
const port=3000
const bodyParser = require('body-parser');
app.use(express.json())
app.use(bodyParser.json());
//post request
app.post('/api/moderation/predict', async(req, res) => {
//get daata and send it in url as paramter
const { text, language } = req.body;
try{
//get data from moderation predict api
const response=await axios.get("https://moderation.logora.fr/predict",{
params:{
text,
language
}
})
//result
res.json(response.data)
}catch(error){
res.send(error)
}
});
//get request
app.post('/api/moderation/score', async(req, res) => {
//get data
const { text, language }=req.body
try{
//get data from moderation score api
const response=await axios.get("https://moderation.logora.fr/score",{
params:{
text,
language
}
})
//result
res.json(response.data)
}catch(error){
res.send(error)
}
});
app.listen(port,()=>{console.log("server running on 3000")})