initial commit
This commit is contained in:
@@ -0,0 +1,42 @@
|
||||
const express = require('express')
|
||||
const app = express()
|
||||
const crypto = require('crypto')
|
||||
|
||||
let d = new Date()
|
||||
let hash = crypto.createHash('md5').update(`${(d.getDate() < 10)?"0"+d.getDate():d.getDate()}/${(d.getMonth()+1 < 10)?"0"+(d.getMonth()+1):d.getMonth()+1}/${d.getFullYear()}`).digest("hex")
|
||||
|
||||
console.log(hash)
|
||||
|
||||
|
||||
const port = 8765
|
||||
|
||||
app.use(express.static(__dirname + "/public"))
|
||||
app.use(express.json())
|
||||
|
||||
app.post('/guess', (req, res) => {
|
||||
let guess = req.body.guess.toLowerCase();
|
||||
if(guess.length != 32){
|
||||
res.json({code:1});
|
||||
return
|
||||
}
|
||||
let result = []
|
||||
for (let i = 0; i < guess.length; i++) {
|
||||
result[i] = 0
|
||||
for (let o = 0; o < hash.length; o++) {
|
||||
if(hash[o] == guess[i] && i != o){
|
||||
result[i] = 1
|
||||
}else if(hash[o] == guess[i] && i == o){
|
||||
result[i] = 2
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
res.json({
|
||||
code:0,
|
||||
response:result
|
||||
})
|
||||
})
|
||||
|
||||
app.listen(port, () => {
|
||||
console.log(`App listening on port ${port}`)
|
||||
})
|
||||
Reference in New Issue
Block a user