This repository has been archived by the owner on Aug 13, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
app.js
111 lines (93 loc) · 2.03 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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
var express = require('express');
var app = express();
var path = require('path');
const bodyParser = require('body-parser');
var exphbs = require('express-handlebars');
var SpellChecker = require('simple-spellchecker');
var axios = require('axios');
const arr = [];
var two = [];
var three = [];
var four = [];
var five = [];
var six = [];
var seven = [];
var eight = [];
var nine = [];
var ten = [];
//view engine
app.engine('.hbs', exphbs({extname: '.hbs'}));
app.set('view engine', '.hbs');
//midelware
// parse application/x-www-form-urlencoded
app.use(bodyParser.urlencoded({ extended: false }))
// parse application/json
app.use(bodyParser.json());
app.use(express.static('public'));
app.get('/',(req,res)=>{
res.render('index');
});
app.post('/',(req,res)=>{
var word = req.body.word;
axios.get(`http://www.anagramica.com/all/:${word}`)
.then((response)=>{
for(let x=0;x<response.data.all.length;x++){
if(response.data.all[x].length==10){
ten.push(' '+response.data.all[x]);
}
if(response.data.all[x].length==9){
nine.push(' '+response.data.all[x]);
}
if(response.data.all[x].length==8){
eight.push(' '+response.data.all[x]);
}
if(response.data.all[x].length==7){
seven.push(' '+response.data.all[x]);
}
if(response.data.all[x].length==6){
six.push(' '+response.data.all[x]);
}
if(response.data.all[x].length==5){
five.push(' '+response.data.all[x]);
}
if(response.data.all[x].length==4){
four.push(' '+response.data.all[x]);
}
if(response.data.all[x].length==3){
three.push(' '+response.data.all[x]);
}
if(response.data.all[x].length==2){
two.push(' '+response.data.all[x]);
}
}
console.log(arr);
res.render('index',{
two:two,
three:three,
four:four,
five:five,
six:six,
seven:seven,
eight:eight,
nine:nine,
ten:ten,
bol:1,
scram:req.body.word
});
two = [];
three = [];
four = [];
five = [];
six = [];
seven = [];
eight = [];
nine = [];
ten = [];
})
.catch((err)=>{
console.log(err);
})
})
app.listen(process.env.PORT || 3000,()=>{
console.log('Server up on 3000')
});