“静态”路由我的Python应用程序规则在我的AWS弹性青苗应用程序(和其他地方)行为异常,出现覆盖所有其他规则。例如,使用下面的两个函数,在我的开发机器和其他AWS上的测试服务器上,routes
列出最后的静态规则,并且match_route
显示其他非静态规则匹配以“static /”开头的路径。 ..'。如预期的那样,如果我导航到在非AWS机器上具有以static/...
开头的路径的页面,则会匹配其中一个(非静态)规则。但是,在AWS-EB上,(只有),服务器的静态规则将针对此类路径调用!为什么AWS Elastic Beanstalk Python先于其他所有人优先插入“静态”规则?
为什么以及如何AWS-EB“插入”领先于所有其他人的这个规则?如何在AWS上禁用此行为,或者在我的非AWS系统中复制它?
application.url_map.host_matching = True
# ...
def routes(verbose, wide):
"""List routes supported by the application"""
for rule in sorted(app.url_map.iter_rules()):
if verbose:
fmt = "{:45s} {:30s} {:30s}" if wide else "{:35s} {:25s} {:25s}"
line = fmt.format(rule, rule.endpoint, ','.join(rule.methods))
else:
fmt = "{:45s}" if wide else "{:35s}"
line = fmt.format(rule)
print(line)
def match_route(host, match):
"""Match a route for a given host"""
if match is not None:
urls = app.url_map.bind(host)
try:
m = urls.match(match, "GET")
z = '{}({})'.format(m[0], ','.join(["{}='{}'".format(arg, m[1][arg]) for arg in m[1]] +
["host='{}'".format(host)]))
return z
except NotFound:
return