Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import web
- from web import form
- urls = (
- '/', 'index',
- '/contact', 'contact',
- )
- app = web.application(urls, globals())
- db = web.database(dbn='mysql', user='username', pw='password', db='dbname')
- render = web.template.render('templates/')
- contactForm = form.Form(
- form.Textbox('name',
- form.notnull,
- description = 'Your Name'
- ),
- form.Textbox('email',
- form.notnull,
- description = 'Your Email'
- ),
- form.Textbox('subject',
- form.notnull,
- description = 'Subject',
- value = 'I\'m going to buy you something'
- ),
- form.Textarea('message',
- form.notnull,
- description = 'Message'
- )
- )
- class index:
- def GET(self):
- contactform = contactForm()
- return render.index(contactform)
- class contact:
- def POST(self):
- contactform = contactForm()
- if not contactform.validates():
- return render.index(contactform)
- else:
- i = web.input()
- PostageApp('apikey').send_message('youremailaddr', i.email, i.subject, { 'text/plain': i.message })
- raise web.seeother('/')
- if __name__ == "__main__":
- app.run()
Add Comment
Please, Sign In to add comment