Flask render_模板在Heroku上不起作用

2024-05-29 00:20:59 发布

您现在位置:Python中文网/ 问答频道 /正文

编辑: 我想这可能与to the comments posted here有关

我还要补充一点,我没有在virtualenv中推这个,因为我为Ipython安装了一条Python,据说它们不能一起玩得很好。。。这是问题的另一个可能根源


我正在尝试部署一个flask应用程序,它在本地和foreman上运行良好,但是在heroku上部署时会出现500个错误。它连接到我的数据库并打印我告诉它的任何内容,直到在我的初始方法中呈现模板为止。在

这是我的堆栈跟踪。在

Traceback (most recent call last):
    response = self.full_dispatch_request()
    reraise(exc_type, exc_value, tb)
  File "/app/.heroku/python/lib/python2.7/site-packages/flask/app.py", line 1475, in full_dispatch_request
    rv = self.handle_user_exception(e)
    reraise(exc_type, exc_value, tb)
    context, ctx.app)
  File "/app/.heroku/python/lib/python2.7/site-packages/flask/templating.py", line 128, in render_template
  File "/app/.heroku/python/lib/python2.7/site-packages/flask/app.py", line 1817, in wsgi_app
    return render_template('/index.html')
  File "/app/.heroku/python/lib/python2.7/site-packages/jinja2/environment.py", line 742, in handle_exception
  File "/app/.heroku/python/lib/python2.7/site-packages/webassets/bundle.py", line 685, in urls
  File "/app/.heroku/python/lib/python2.7/site-packages/webassets/ext/jinja2.py", line 181, in _render_assets
  File "/app/.heroku/python/lib/python2.7/site-packages/flask/app.py", line 1461, in dispatch_request
  File "/app/.heroku/python/lib/python2.7/site-packages/jinja2/environment.py", line 969, in render
    urls = bundle.urls(env=env)
  File "/app/.heroku/python/lib/python2.7/site-packages/flask/app.py", line 1477, in full_dispatch_request
  File "/app/templates/index.html", line 10, in top-level template code
    reraise(exc_type, exc_value, tb)
    rv = template.render(context)
  File "/app/.heroku/python/lib/python2.7/site-packages/webassets/bundle.py", line 504, in _build
    force, disable_cache=disable_cache, extra_filters=extra_filters)
  File "/app/.heroku/python/lib/python2.7/site-packages/webassets/merge.py", line 219, in _wrap_cache
  File "/app/.heroku/python/lib/python2.7/site-packages/flask/templating.py", line 110, in _render
    getattr(filter, type)(data, out, **kwargs_final)
  File "/app/.heroku/python/lib/python2.7/site-packages/webassets/bundle.py", line 429, in _merge_and_apply
  File "/app/.heroku/python/lib/python2.7/site-packages/webassets/merge.py", line 272, in apply
  File "/app/.heroku/python/lib/python2.7/site-packages/flask/app.py", line 1381, in handle_user_exception
  File "/app/.heroku/python/lib/python2.7/site-packages/webassets/filter/sass.py", line 122, in _apply_sass
    return self.environment.handle_exception(exc_info, True)
    rv = self.dispatch_request()
    errread, errwrite)
  File "/app/.heroku/python/lib/python2.7/subprocess.py", line 1327, in _execute_child
    kwargs=item_data)
    *args, **kwargs)
  File "/app/.heroku/python/lib/python2.7/subprocess.py", line 710, in __init__
  File "/app/.heroku/python/lib/python2.7/site-packages/webassets/bundle.py", line 647, in _urls
    return self._wrap_cache(key, func)
    raise child_exception
  File "/app/.heroku/python/lib/python2.7/site-packages/webassets/filter/sass.py", line 141, in input
    self._apply_sass(_in, out, os.path.dirname(source_path))
    return self.view_functions[rule.endpoint](**req.view_args)
    content = func().getvalue()
  File "/app/.heroku/python/lib/python2.7/site-packages/webassets/merge.py", line 252, in func
  File "/app/app.py", line 110, in index
    shell=(os.name == 'nt'))
OSError: [Errno 2] No such file or direct

它连接到db fine和index方法,但在呈现模板上失败。。。。在

这是我的代码:

^{pr2}$

我的文件结构是扁平的:

app/
    --app.y
    --requirements.txt
    --Procfile
    ---static/
    ---templates/

还有我的要求.txt里面有:

Flask==0.10.1
Flask-Assets==0.9
Jinja2==2.7.2
Werkzeug==0.9.4
beautifulsoup4==4.3.1
html5lib==0.999
pymongo==2.7.1
python-dateutil==1.5

奇怪的是我没有得到一个关于找不到模板的jinga错误。。。找不到文件是操作系统错误。。。有什么想法吗?在


Tags: inpyselfappflaskherokulibpackages

热门问题