summaryrefslogtreecommitdiffstats
path: root/punani/tightnani/tightnani-web.py
diff options
context:
space:
mode:
authormakefu <github@syntax-fehler.de>2011-11-14 03:34:23 +0100
committermakefu <github@syntax-fehler.de>2011-11-14 03:34:23 +0100
commit8560556d854f777d3cc0cf468d80d0e08860c1e5 (patch)
treef37d0b1d0281016593fdc9daf9e2584f62eb77d7 /punani/tightnani/tightnani-web.py
parent9d7c537fd978f4848480b189ddb21f3b44eedec0 (diff)
parent0fe81e9301efa359fba9f7eae498cc69cbe1f87f (diff)
Merge branch 'master' of github.com:krebscode/painload
Diffstat (limited to 'punani/tightnani/tightnani-web.py')
-rwxr-xr-xpunani/tightnani/tightnani-web.py48
1 files changed, 48 insertions, 0 deletions
diff --git a/punani/tightnani/tightnani-web.py b/punani/tightnani/tightnani-web.py
new file mode 100755
index 00000000..52f5004f
--- /dev/null
+++ b/punani/tightnani/tightnani-web.py
@@ -0,0 +1,48 @@
+#!/usr/bin/python
+
+import web
+import json
+
+urls = (
+ '/', 'Index',
+ '/dump','Dump',
+ '/reload','Reload',
+ '/(.+)/(.+)', 'ArchFinder',
+)
+
+
+PDB_FILE="tightnani_db"
+
+pdb= json.load(open(PDB_FILE))
+
+class Index:
+ def GET(self):
+ ret = """Welcome to the Tightnani API<br/>
+Retrieve a package name for your distribution with: /ARCH/PKG"""
+ return ret
+
+class Reload:
+ def GET(self):
+ pdb= json.load(open(PDB_FILE))
+ return "DB reloaded"
+
+
+class Dump:
+ def GET(self):
+ return json.dumps(pdb,sort_keys=True,indent=4)
+
+class ArchFinder:
+ def GET(self,packer,package):
+ if not packer or not package: web.BadRequest()
+ else:
+ packer = pdb['packer-symlinks'].get(packer,packer) #try to resolve similar packers
+ ret = pdb.get(package,{}).get(packer,False)
+ if not ret: web.NotFound()
+ else: return ret
+
+
+
+if __name__ == "__main__":
+ app = web.application(urls,globals())
+ app.internalerror = web.debugerror
+ app.run()