If a PK has slashes (eg, a file path), they are not encoded properly and break Flask routing. For example, a PK value of /tmp/foo will route to /table_name/update/tmp/foo.
Flask provides url_map.converters['path'] for this, EXCEPT that the path converter still won't touch a leading slash, which needs to be encoded for this particular example.
Rather than worrying about what characters need to be url-encoded, or whether they are at the start or end of a param, etc, just base64 the PK value so no matter what is in there, it's url-safe.
If a PK has slashes (eg, a file path), they are not encoded properly and break Flask routing. For example, a PK value of
/tmp/foo
will route to/table_name/update/tmp/foo
.Flask provides
url_map.converters['path']
for this, EXCEPT that thepath
converter still won't touch a leading slash, which needs to be encoded for this particular example.Rather than worrying about what characters need to be url-encoded, or whether they are at the start or end of a param, etc, just base64 the PK value so no matter what is in there, it's url-safe.
http://exploreflask.com/en/latest/views.html#custom-converters