diff options
author | Alexander Sulfrian <alexander@sulfrian.net> | 2011-09-27 02:43:39 +0200 |
---|---|---|
committer | Alexander Sulfrian <alexander@sulfrian.net> | 2011-09-27 02:43:39 +0200 |
commit | 5617c91957851165722a23f4d57ac6b7a3170ce0 (patch) | |
tree | 0de1dac6d95de78138b2fbbc2d4f59f9c2ca7e39 /index.py | |
download | sites-5617c91957851165722a23f4d57ac6b7a3170ce0.tar.gz sites-5617c91957851165722a23f4d57ac6b7a3170ce0.tar.bz2 sites-5617c91957851165722a23f4d57ac6b7a3170ce0.zip |
initial import
Diffstat (limited to 'index.py')
-rwxr-xr-x | index.py | 56 |
1 files changed, 56 insertions, 0 deletions
diff --git a/index.py b/index.py new file mode 100755 index 0000000..bd0a491 --- /dev/null +++ b/index.py @@ -0,0 +1,56 @@ +#!/usr/bin/env python + +from web import template, form, application, ctx +from socket import gethostbyaddr + +urls = ( + '/', 'index', + '/neu.*', 'new', + '/new', 'new', + '/help/spam.*', 'spam', +) + +render = template.render('templates/', base='layout'); + +create_form = form.Form( + form.Textbox('name', + form.notnull, + description = 'Name of your list'), + form.Textbox('email', + form.notnull, + form.regexp('.*fu-berlin\.de', 'E-mail address should end with fu-berlin.de'), + description = 'Your E-mail address'), + ) + +class index: + def GET(self): + return self.POST(); + + def POST(self): + return render.index() + +class spam: + def GET(self): + return self.POST(); + + def POST(self): + return render.spam() + +class new: + def GET(self): + form = create_form() + user = {'ip': ctx.ip, 'host': gethostbyaddr(ctx.ip)[0]} + return render.new(form, user) + + def POST(self): + form = create_form() + user = {'ip': ctx.ip, 'host': gethostbyaddr(ctx.ip)[0]} + if not form.validates(): + return render.new(form, user) + else: + return "Done." + + +if __name__ == "__main__": + app = application(urls, globals(), autoreload=False) + app.run() |