Created
August 17, 2012 07:57
-
-
Save akhenakh/3376839 to your computer and use it in GitHub Desktop.
negative float for flask
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from werkzeug.routing import NumberConverter, ValidationError | |
class NegativeFloatConverter(NumberConverter): | |
regex = r'\-?\d+\.\d+' | |
num_convert = float | |
def __init__(self, map, min=None, max=None): | |
NumberConverter.__init__(self, map, 0, min, max) | |
app.url_map.converters['float'] = NegativeFloatConverter |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment