-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathAPI_Server.py
More file actions
36 lines (30 loc) · 839 Bytes
/
API_Server.py
File metadata and controls
36 lines (30 loc) · 839 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
#!/usr/bin/python
from RebootServer import getMiners
import cherrypy
miners = getMiners()
class API(object):
@cherrypy.expose
def index(self):
raise cherrypy.HTTPError(400, "This style of calling the API is not supported.")
# End def
@cherrypy.expose
def restart(self, num=""):
if num is "":
raise cherrypy.HTTPError(400, "Missing the number of the miner to be rebooted.")
else:
for miner in miners:
if miner.miner_num == num:
print ("Rebooting miner %s!" % miner.miner_num)
miner.reboot()
return
# End if
# End for
# End else
# End def
# End class
def main():
cherrypy.quickstart(API())
# End def
if __name__ == '__main__':
main()
# End if