Spaces:
Sleeping
Sleeping
Update server.js
Browse files
server.js
CHANGED
@@ -14,10 +14,22 @@ const delayIncrement = 100
|
|
14 |
const maxDelay = 5000
|
15 |
let currentTranslations = 0
|
16 |
|
17 |
-
|
18 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
19 |
}
|
20 |
|
|
|
|
|
21 |
console.log('File system loaded')
|
22 |
|
23 |
app.post('/translate', async (req, res) => {
|
@@ -44,7 +56,9 @@ app.post('/translate', async (req, res) => {
|
|
44 |
console.log(`"${text}" -> "${result.text}"`)
|
45 |
|
46 |
} catch (error) {
|
47 |
-
|
|
|
|
|
48 |
} finally {
|
49 |
currentTranslations-- // λ²μ μ²λ¦¬κ° λλλ©΄ 1 κ°μ
|
50 |
}
|
@@ -52,7 +66,7 @@ app.post('/translate', async (req, res) => {
|
|
52 |
|
53 |
app.get('/', (req, res) => {
|
54 |
const delayMessage = fs.existsSync('delay.txt') ? fs.readFileSync('delay.txt', 'utf8') : '0'
|
55 |
-
const statusMessage = `μλ²κ° ꡬλλμμ΅λλ€. νμ¬ λλ μ΄ μκ°μ ${
|
56 |
res.send(statusMessage)
|
57 |
|
58 |
})
|
|
|
14 |
const maxDelay = 5000
|
15 |
let currentTranslations = 0
|
16 |
|
17 |
+
function delayFileTermination(delay) {
|
18 |
+
if (fs.existsSync('delay.txt')) {
|
19 |
+
delay = parseInt(fs.readFileSync('delay.txt', 'utf8'))
|
20 |
+
}else{
|
21 |
+
fs.writeFile('delay.txt', 'delay:{$delay}', function(err){
|
22 |
+
if(err = null){
|
23 |
+
console.log('success')
|
24 |
+
}else{
|
25 |
+
console.log('fail')
|
26 |
+
}
|
27 |
+
})
|
28 |
+
}
|
29 |
}
|
30 |
|
31 |
+
|
32 |
+
|
33 |
console.log('File system loaded')
|
34 |
|
35 |
app.post('/translate', async (req, res) => {
|
|
|
56 |
console.log(`"${text}" -> "${result.text}"`)
|
57 |
|
58 |
} catch (error) {
|
59 |
+
console.log(error: 'Translation failed') }
|
60 |
+
delay = delay + 100
|
61 |
+
console("νμ¬ Delay νμ:" + delay + "ms")
|
62 |
} finally {
|
63 |
currentTranslations-- // λ²μ μ²λ¦¬κ° λλλ©΄ 1 κ°μ
|
64 |
}
|
|
|
66 |
|
67 |
app.get('/', (req, res) => {
|
68 |
const delayMessage = fs.existsSync('delay.txt') ? fs.readFileSync('delay.txt', 'utf8') : '0'
|
69 |
+
const statusMessage = `μλ²κ° ꡬλλμμ΅λλ€. νμ¬ λλ μ΄ μκ°μ ${delay}msμ΄λ©°, νμ¬ μ²λ¦¬ μ€μΈ λ²μ μμ² μλ ${currentTranslations}건μ
λλ€.`
|
70 |
res.send(statusMessage)
|
71 |
|
72 |
})
|