Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/xsleonard/flask-formencode
Flask extension for the form processing & validation library FormEncode
https://github.com/xsleonard/flask-formencode
Last synced: about 1 month ago
JSON representation
Flask extension for the form processing & validation library FormEncode
- Host: GitHub
- URL: https://github.com/xsleonard/flask-formencode
- Owner: xsleonard
- License: mit
- Created: 2013-10-15T00:53:35.000Z (over 11 years ago)
- Default Branch: master
- Last Pushed: 2013-10-17T01:29:00.000Z (over 11 years ago)
- Last Synced: 2024-11-15T06:43:18.507Z (2 months ago)
- Language: Python
- Size: 203 KB
- Stars: 3
- Watchers: 2
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
Flask-FormEncode
================Flask extension for the form processing & validation library [FormEncode](http://www.formencode.org/en/1.2-branch/)
[![PyPI version](https://badge.fury.io/py/Flask-FormEncode.png)](http://badge.fury.io/py/Flask-FormEncode)
[![Build Status](https://travis-ci.org/xsleonard/Flask-FormEncode.png)](https://travis-ci.org/xsleonard/Flask-FormEncode)
[![Coverage Status](https://coveralls.io/repos/xsleonard/Flask-FormEncode/badge.png?branch=master)](https://coveralls.io/r/xsleonard/Flask-FormEncode?branch=master)[Read the complete docs](http://pythonhosted.org/Flask-FormEncode/)
Flask-FormEncode supports python 2.6, 2.7 and pypy. Python 3 support will be added once FormEncode supports it (expected next release).
To run the tests, do `python setup.py test`.
Example:
```python
# app.py
from flask import Flask, redirect, flash, abort
from flask.ext.formencode import Form
from formencode import Invalid, Schema
from formencode.validators import UnicodeStringapp = Flask(__name__)
class LoginSchema(Schema):
username = UnicodeString(strip=True, not_empty=True)@app.route('/')
def index():
return 'Hello'@app.route('/login', methods=['POST'])
def login():
try:
form = Form(LoginSchema)
except Invalid as e:
flash(e.unpack_errors())
abort(400)
else:
flash('Welcome {0}'.format(form['username']))
return redirect(url_for('index'))
```