Skip to main content

web app forms tools

Project description

btform
=======

python web app forms tools

Code is extracted from web.py

install
=======

easy_install btform

pip install btform

example of flask
=================

#!/usr/bin/env python
#coding:utf-8

from flask import Flask
from flask import request
from btform import rules
import btform as form

app = Flask(__name__)

form1 = form.Form(
form.Textbox("name",rules.is_alphanum2(6,32),description=""),
form.Password("passwd",rules.is_alphanum2(6,32),description=""),
form.Textarea("desc",rules.len_of(1,128),description="",rows="5",),
form.Button("submit", type="submit",html="<b>submit</b>"),
)

def render_form(frm):
return "<form action='/' method='POST'>%s</form>"%frm.render()

@app.route('/', methods=['POST', 'GET'])
def hello_world():
iform = form1()
if request.method == 'GET':
return render_form(iform)
elif request.method == 'POST':
if not iform.validates(source=request.form):
return render_form(iform)
else:
return "ok"

if __name__ == '__main__':
app.run()

Project details


Release history Release notifications | RSS feed

This version

0.1

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Files for btform, version 0.1
Filename, size File type Python version Upload date Hashes
Filename, size btform-0.1.linux-x86_64.tar.gz (16.2 kB) File type Dumb Binary Python version any Upload date Hashes View
Filename, size btform-0.1-py2-none-any.whl (10.6 kB) File type Wheel Python version 2.7 Upload date Hashes View

Supported by

Pingdom Pingdom Monitoring Google Google Object Storage and Download Analytics Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN DigiCert DigiCert EV certificate StatusPage StatusPage Status page