python runtime_error ai_generated true

werkzeug.routing.exceptions.BuildError: 无法为端点 'static' 构建 url,值 ['filename']。是否忘记指定值 ['filename']?

werkzeug.routing.exceptions.BuildError: Could not build url for endpoint 'static' with values ['filename']. Did you forget to specify values ['filename']?

ID: python/flask-url-for-external-https

其他格式: JSON · Markdown 中文 · English
80%修复率
88%置信度
0证据数
2024-06-15首次发现

版本兼容性

版本状态引入弃用备注
3.x active — — —

根因分析

调用 url_for('static', ...) 时未提供必需的 filename 参数,或端点名称拼写错误。

English

url_for('static', ...) was called without the required filename argument, or the endpoint name was misspelled.

generic

解决方案

  1. 98% 成功率
    url_for('static', filename='css/app.css')
  2. 85% 成功率
    print([r.endpoint for r in app.url_map.iter_rules()])

无效尝试

常见但无效的做法:

  1. 85% 失败

    Breaks asset links; static files 404 in production.

  2. 70% 失败

    Ignores url_prefix and CDN configuration.