Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Select an option

  • Save questionlp/98d1c7c9a5b2c1776212df0975af56b3 to your computer and use it in GitHub Desktop.

Select an option

Save questionlp/98d1c7c9a5b2c1776212df0975af56b3 to your computer and use it in GitHub Desktop.
Flask Signed Integer URL Map Converter
class SignedIntConverter(IntegerConverter):
    regex = r'-?\d+'

app.url_map.converters['signed_int'] = SignedIntConverter

Then use <signed_int:user_id> in your route.

Source: pallets/flask#2643 (comment)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment