Skip to content

Instantly share code, notes, and snippets.

@akhenakh
Created August 17, 2012 07:57
Show Gist options
  • Save akhenakh/3376839 to your computer and use it in GitHub Desktop.
Save akhenakh/3376839 to your computer and use it in GitHub Desktop.
negative float for flask
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