aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVikraman Choudhury <vikraman.choudhury@gmail.com>2011-08-04 03:21:32 +0530
committerVikraman Choudhury <vikraman.choudhury@gmail.com>2011-08-04 03:21:32 +0530
commitff90e73798944f2d3a616729f8ab159d48366247 (patch)
treebba8c888e57a7b20a3afb391298e2b2a24f7ec04
parentfix profile json export (diff)
downloadgentoostats-ff90e73798944f2d3a616729f8ab159d48366247.tar.gz
gentoostats-ff90e73798944f2d3a616729f8ab159d48366247.tar.bz2
gentoostats-ff90e73798944f2d3a616729f8ab159d48366247.zip
add input form for host uuid
-rwxr-xr-xserver/app.py1
-rw-r--r--server/host.py23
-rw-r--r--server/templates/host_input.html7
3 files changed, 29 insertions, 2 deletions
diff --git a/server/app.py b/server/app.py
index fcef84f..0cd4b9b 100755
--- a/server/app.py
+++ b/server/app.py
@@ -32,6 +32,7 @@ urls = (
r'/use/(.+)', 'Use',
r'/use', 'Use',
r'/host/(.+)', 'Host',
+ r'/host', 'Host',
r'/search', 'Search'
)
diff --git a/server/host.py b/server/host.py
index fab706c..7fd8132 100644
--- a/server/host.py
+++ b/server/host.py
@@ -3,11 +3,22 @@ import web
import json
import helpers
import config
+from web import form
from config import render, db
+host_form = form.Form(
+ form.Textbox('uuid', description = 'UUID'),
+ form.Button('submit', description = 'Submit')
+ )
+
class Host(object):
- def GET(self, str_uuid):
+ def GET(self, *args):
+ if len(args) == 0:
+ form = host_form()
+ return render.host_input(form)
+
+ str_uuid = args[0]
if not helpers.is_uuid(str_uuid):
return config.notfound()
@@ -60,7 +71,15 @@ class Host(object):
else:
return render.host(host_data)
- def POST(self, str_uuid):
+ def POST(self, *args):
+ if len(args) == 0:
+ form = host_form()
+ if not form.validates():
+ return render.host_input(form)
+ else:
+ raise web.seeother('/host/' + form['uuid'].value)
+
+ str_uuid = args[0]
post_data = json.JSONDecoder().decode(web.data())
#TODO: Handle exceptions
diff --git a/server/templates/host_input.html b/server/templates/host_input.html
new file mode 100644
index 0000000..ae0e2ec
--- /dev/null
+++ b/server/templates/host_input.html
@@ -0,0 +1,7 @@
+$def with (form)
+$var title: Host
+
+<h2>Input host uuid</h2>
+<form method="POST">
+ $:form.render()
+</form>