-
Notifications
You must be signed in to change notification settings - Fork 13
Expand file tree
/
Copy pathcode.py
More file actions
executable file
·29 lines (23 loc) · 757 Bytes
/
code.py
File metadata and controls
executable file
·29 lines (23 loc) · 757 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
#!/usr/bin/env python
import os
import web
from zk import ZooKepperConnection
urls = ('/(.*)', 'node')
render = web.template.render('templates/')
try:
zkc = ZooKepperConnection(os.environ["ZOOKEEPER"])
except:
zkc = ZooKepperConnection("127.0.0.1:2181")
class node:
def GET(self, url = ""):
name = url if not url.endswith('/') else url[:-1]
home = web.ctx.homedomain + ('/' + name if name != "" else '')
raw_data = zkc.raw_data(name)
data = raw_data[0]
info = raw_data[1]
children = zkc.children(name)
return render.page(home, name, data, info, children)
if __name__ == '__main__' :
app = web.application(urls, globals())
app.internalerror = web.debugerror
app.run()