-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathindex.js
More file actions
37 lines (34 loc) · 688 Bytes
/
index.js
File metadata and controls
37 lines (34 loc) · 688 Bytes
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
#!/usr/bin/env node
const app = require('express')()
const command = require('./command')
const port = process.env.PORT || 8888
app.get('/', (req, res) => {
res.send(`
<pre>
Usage:
GET /stats - Get the miner status
POST /restart - restart the minerœ
</pre>
`)
})
app.get('/stats', (req, res) => {
command('miner_getstat1')
.then(data => {
res.json(data)
})
.catch(err => {
res.status(500).json(err)
})
})
app.post('/restart', (req, res) => {
command('miner_restart')
.then(data => {
res.json(data)
})
.catch(err => {
res.status(500).json(err)
})
})
app.listen(port, _ => {
console.log('Listening on ' + port)
})