鉴于Flask Routes are not pattern matched from top to bottom,如何处理以下问题?
我有以下路线:
> /< poll_key> / close
> /< poll_key> /< participant_key>
如果我向http:// localhost:5000 / example-poll-key / close发出请求,Flask将其匹配为模式2,将字符串’close’分配给< participant_key> URL参数.如何在< participant_key>之前使< poll_key> / close路线匹配?路线?
最佳答案
请参阅我对同一问题的其他答案:https://stackoverflow.com/a/17146563/880326.
@H_301_25@/
其中没有定义转换器
@H_301_25@class NoConverter(BaseConverter): def __init__(self,map,*items): BaseConverter.__init__(self,map) self.items = items def to_python(self,value): if value in self.items: raise ValidationError() return value
更新:
我错过了match_compare_key:
>对于静态端点:(真,-2,[(0,-6),(1,200)])
> for /< poll_key> / close