Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/299.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/heroku/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 带烧瓶的heroku上出现500内部服务器错误_Python_Heroku_Flask_Internal Server Error - Fatal编程技术网

Python 带烧瓶的heroku上出现500内部服务器错误

Python 带烧瓶的heroku上出现500内部服务器错误,python,heroku,flask,internal-server-error,Python,Heroku,Flask,Internal Server Error,我在Heroku和Flask上发现500个内部服务器错误。我的应用程序在本地主机上运行得非常好。尝试广泛搜索堆栈溢出,但未找到答案 这是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('in

我在Heroku和Flask上发现500个内部服务器错误。我的应用程序在本地主机上运行得非常好。尝试广泛搜索堆栈溢出,但未找到答案

这是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(\uuuuuu name,template\u folder='templates')
,但没有成功。请帮忙。

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

我看不到
app.run()
,但您说您正在Flask的内置服务器上本地运行它(如端口号所示)。对吗?在这种情况下,我怀疑问题与环境有关。@jsfan我正在运行它<代码>如果uuu name uuuu=='uuuuu main uuuuuu':app.run()。它在本地主机上正确运行。请您详细说明环境可能有什么问题?如果可以在uWSGI和web服务器中本地运行,请尝试。我不知道什么可能与环境相关,但这显然是两种设置之间的主要区别。您确定模板目录与其他文件一起上载吗?我不使用heroku,但我记得部署类似于使用git这样的VCS,所以可能你忘了添加模板。你能详细说明一下吗?我没有完全理解它。