diff options
-rwxr-xr-x | server/app.py | 1 | ||||
-rw-r--r-- | server/host.py | 23 | ||||
-rw-r--r-- | server/templates/host_input.html | 7 |
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> |