在带有烧瓶的heroku上有500个内部服务器错误

时间:2016-02-23 09:39:06

标签: python heroku flask internal-server-error

我在使用Flask的Heroku上遇到500内部服务器错误。我的应用程序在localhost http://127.0.0.1:5000/上运行得非常好。尝试在Stack Overflow上进行广泛搜索,但没有找到答案。

这是heroku日志

2016-02-23T09:27:56.657837+00:00 app[web.1]:   File "/app/servertest.py", line 18, in hello_world
2016-02-23T09:27:56.657837+00:00 app[web.1]:     return render_template('index.html')
2016-02-23T09:27:56.657838+00:00 app[web.1]:   File "/app/.heroku/python/lib/python2.7/site-packages/flask/templating.py", line 127, in render_template
2016-02-23T09:27:56.657838+00:00 app[web.1]:     return _render(ctx.app.jinja_env.get_or_select_template(template_name_or_list),
2016-02-23T09:27:56.657839+00:00 app[web.1]:   File "/app/.heroku/python/lib/python2.7/site-packages/jinja2/environment.py", line 851, in get_or_select_template
2016-02-23T09:27:56.657840+00:00 app[web.1]:     return self.get_template(template_name_or_list, parent, globals)
2016-02-23T09:27:56.657841+00:00 app[web.1]:   File "/app/.heroku/python/lib/python2.7/site-packages/jinja2/environment.py", line 812, in get_template
2016-02-23T09:27:56.657842+00:00 app[web.1]:     return self._load_template(name, self.make_globals(globals))
2016-02-23T09:27:56.657842+00:00 app[web.1]:   File "/app/.heroku/python/lib/python2.7/site-packages/jinja2/environment.py", line 774, in _load_template
2016-02-23T09:27:56.657843+00:00 app[web.1]:     cache_key = self.loader.get_source(self, name)[1]
2016-02-23T09:27:56.657844+00:00 app[web.1]:   File "/app/.heroku/python/lib/python2.7/site-packages/flask/templating.py", line 64, in get_source
2016-02-23T09:27:56.657844+00:00 app[web.1]:     raise TemplateNotFound(template)
2016-02-23T09:27:56.657845+00:00 app[web.1]: TemplateNotFound: index.html

这是我的一些代码

from flask import Flask, request, send_from_directory, send_file, jsonify, render_template
from PIL import Image
import commands
import requests
import json
import os
from werkzeug import secure_filename
import sys
import logging

app = Flask(__name__)

app.logger.addHandler(logging.StreamHandler(sys.stdout))
app.logger.setLevel(logging.ERROR)

@app.route('/')
def hello_world():
    return render_template('index.html')

这是我的文件树

+-- app
|   flaskFile.py
|   templates
|   +-- index.html
|   +-- ...

即使尝试app = Flask(__name__,template_folder='templates'),但它也无效。请帮忙。

1 个答案:

答案 0 :(得分:2)

现在对我有用。我有一个重命名问题,因为我没有使用CLI重命名。如果您正在阅读本文,请始终使用CLI。