forked from Arpit0m/voice-translation-_-v1
-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.js
65 lines (34 loc) · 1.09 KB
/
app.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
const express = require("express");
const bodyParser = require("body-parser");
const translate = require('@vitalets/google-translate-api');
const tunnel = require('tunnel');
const ejs = require("ejs");
const app = express();
const output = [" "];
app.set("view engine", "ejs");
app.use(express.static("public"));
app.use(bodyParser.urlencoded({extended :true}));
app.get("/",function(req,res){
res.render("home");
})
app.get("/translate" ,function(req,res){
res.render("translate" , {output : output});
});
app.get("/find",function(req,res){
res.render("find");
});
app.post("/translate", function(req,res){
const inputText = req.body.text;
let inputLang = req.body.inputLang;
let outputLang = req.body.outputLang;
let outputText =" ";
console.log(req.body);
translate(inputText ,{ to : outputLang}).then(function(response){
outputText = response.text;
output.push(outputText);
res.redirect("/translate");
});
});
app.listen(3000, function(req,res){
console.log("server running");
})