烧瓶冷冻不起作用,而烧瓶是好的

时间:2013-07-18 10:46:49

标签: python flask

我有一个使用Flask的网站。主程序很长,所以我用a paste向你展示代码。当我使用./site serve --debug运行它时效果很好,但我无法使用Flask-freeze冻结它。我有这个错误:

$ ./site build                       
Building website...
./site:240: MimetypeMismatchWarning: Filename extension of u'sitemap.xml' (type application/xml) does not match Content-Type: text/html; charset=utf-8
  freezer.freeze()
Traceback (most recent call last):
  File "./site", line 346, in <module>
    parser.dispatch()
  File "/home/guillaume/nicolas.perriault.net/env/lib/python2.7/site-packages/argh/helpers.py", line 53, in dispatch
    return dispatch(self, *args, **kwargs)
  File "/home/guillaume/nicolas.perriault.net/env/lib/python2.7/site-packages/argh/dispatching.py", line 123, in dispatch
    for line in lines:
  File "/home/guillaume/nicolas.perriault.net/env/lib/python2.7/site-packages/argh/dispatching.py", line 199, in _execute_command
    for line in result:
  File "/home/guillaume/nicolas.perriault.net/env/lib/python2.7/site-packages/argh/dispatching.py", line 182, in _call
    result = args.function(*positional, **keywords)
  File "./site", line 240, in build
    freezer.freeze()
  File "/home/guillaume/nicolas.perriault.net/env/lib/python2.7/site-packages/flask_frozen/__init__.py", line 140, in freeze
    new_filename = self._build_one(url)
  File "/home/guillaume/nicolas.perriault.net/env/lib/python2.7/site-packages/flask_frozen/__init__.py", line 250, in _build_one
    % (response.status, url))
ValueError: Unexpected status '500 INTERNAL SERVER ERROR' on URL /403.html

如果我在site.py中删除了关于403.html的部分,我在404,然后是500,然后是contact.html,然后是/时遇到同样的错误。我找不到原因。有没有人有想法?

1 个答案:

答案 0 :(得分:4)

在冻结应用程序时启用测试。它应该产生更多关于错误的信息。

@command
def build():
    """ Builds this site.
    """
    print("Building website...")
    app.debug = False
    app.testing = True
    asset_manager.config['ASSETS_DEBUG'] = False
    freezer.freeze()
    local("cp ./static/*.ico ./build/")
    local("cp ./static/*.txt ./build/")
    local("cp ./static/*.xml ./build/")
    print("Done.")

Frozen-flask使用app.test_client()查看docs