-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathserver.js
More file actions
26 lines (21 loc) · 771 Bytes
/
Copy pathserver.js
File metadata and controls
26 lines (21 loc) · 771 Bytes
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
const express = require('express');
const app = express();
const {convertToDotless} = require('./utils/convertToDotless')
app.use(express.json({limit: '3mb'}));
app.set('view engine', 'ejs');
app.use(express.static(__dirname + '/public'));
app.post('/convert', async (req,res)=> {
var text = req.body.text;
if(!text) return res.status(400).send({error: 'Empty text.'})
var newText = [];
for (let index = 0; index < text.length; index++) {
await convertToDotless(text[index], index, newText, text);
}
res.send({ "text": newText.join('') })
});
app.get('/', async (req, res) => {
res.render('index');
});
// Server
const port = Number(process.env.PORT || 3000);
app.listen(port, () => console.log(`App listening on port ${port}!`));