简体   繁体   English

烧瓶冻结,但烧瓶没问题

[英]Flask-frozen don’t work whereas flask is ok

I have a website using Flask. 我有一个使用Flask的网站。 The main program is pretty long, so I've used a paste to show you the code. 主程序很长,因此我使用粘贴向您展示了代码。 When I run it with ./site serve --debug it works perfectly, but I can't freeze it with Flask-frozen. 当我使用./site serve --debug运行它时,它可以完美运行,但是我无法用Flask-frozen将其冻结。 I have this error : 我有这个错误:

$ ./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

If I delete the part about 403.html in site.py, I have the same error with 404, then 500, then contact.html, then /. 如果我在site.py中删除了关于403.html的部分,则我会看到与404相同的错误,然后是500,然后是contact.html,然后是/。 And I can't find why. 而且我找不到原因。 Is there anybody who has an idea ? 有谁有主意吗?

Enable testing while freezing your application. 在冻结应用程序的同时启用测试。 It should produce more information about error. 它应该产生有关错误的更多信息。

@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 uses app.test_client() look at it's docs . Frozen-flask使用app.test_client()查看其docs

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM