使用动态网址捕获 request.path
Catch request.path with dynamic urls
在 flask 中,当 request.path 符合条件时,我需要添加一个 class。
我的问题是 request.path 会像
/users/history/job/john
/users/history/job/pedro
/users/history/role/fabio
/users/history/role/pedro
...
我怎样才能捕捉到这种情况?由于 url 的动态部分,这将不起作用。有什么类型的通配符吗?
{% if request.path == "/users/history/job" %}active{% endif %}>
{% if request.path == "/users/history/role" %}active{% endif %}>
尝试这样的事情:
{% if "/users/history/job/" in request.path %}active{% endif %}>
{% if "/users/history/role/" in request.path %}active{% endif %}>
在 flask 中,当 request.path 符合条件时,我需要添加一个 class。
我的问题是 request.path 会像
/users/history/job/john
/users/history/job/pedro
/users/history/role/fabio
/users/history/role/pedro
...
我怎样才能捕捉到这种情况?由于 url 的动态部分,这将不起作用。有什么类型的通配符吗?
{% if request.path == "/users/history/job" %}active{% endif %}>
{% if request.path == "/users/history/role" %}active{% endif %}>
尝试这样的事情:
{% if "/users/history/job/" in request.path %}active{% endif %}>
{% if "/users/history/role/" in request.path %}active{% endif %}>