2013-07-18 121 views
2

我有一個網站使用Flask。主程序很長,所以我用a paste來顯示代碼。當我用./site serve --debug運行它時,它可以很好地工作,但我無法用燒瓶冷凍它。我有這樣的錯誤:燒瓶凍結不起作用,而燒瓶是好的

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

什麼在您的模板?可能是一些'base.html'?嘗試在運行'./site serve --debug'時尋址'/ 403.html'。有沒有錯誤? – twil

+0

當我去'403.html' 沒有錯誤我有一個'base.html',但我不認爲這個錯誤來自他。你想看代碼嗎? –

回答

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.") 

冷凍瓶使用app.test_client()看看它的docs

+0

非常感謝。有了這個,我發現代碼中有錯誤。如何解決它?刪除錯誤的代碼。 :D –

+0

asset_manager從哪裏來? –

+1

我想這是http://elsdoerfer.name/docs/flask-assets/。糊狀物已經死亡是一件可疑的事情:/ – twil