-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
43 lines (36 loc) · 955 Bytes
/
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
/* jshint esversion: 6 */
import cors from 'cors';
import fs from 'fs';
import express from 'express';
import bodyParser from 'body-parser';
import synthesis from './module/synthesis';
const app = express();
app.use(bodyParser.urlencoded({ extended: false }));
app.use(bodyParser.json());
app.use(cors());
const corsOptions = {
origin: 'http://localhost:3000',
optionsSuccessStatus: 200,
};
app.post('/allo', cors(corsOptions), async (req,res) => {
let path = await synthesis(req.body.text, req.body.lang,req.headers.host, (err, fileLink) => {
if (err) {
console.log('error pico');
} else {
res.send(fileLink)
}
});
// console.log("4 "+fs.existsSync(path));
// while(!fs.existsSync(path)){
// fs.existsSync(path);
// console.log('haha');
// }
// console.log(path);
// res.send(path);
});
app.get('/',(req, res) => {
res.send('nami');
});
app.listen(8080, () => {
console.log('Examplxe app listening on port 8080!');
});