render_template 在 aws beanstalk 中给出内部服务器错误

render_template giving internal server error in aws beanstalk

我正在尝试在 AWS elasticbeanstalk 中托管一个简单的应用程序,但是当我使用 render_template 时它给我这个错误“Internal Server Error 服务器遇到内部错误,无法完成您的请求。要么是服务器过载,要么是应用程序出错。"

这是我的烧瓶代码,

from flask import Flask, render_template
import requests

application = Flask(__name__, template_folder="templates", static_folder="static")

@application.route("/")
def index():
    return render_template('index.html')

# run the app.
if __name__ == "__main__":
    application.debug = True
    application.run()

我的HTML代码,

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
</head>
<body>

<div>
    <h1>Hello, Flask!</h1>
</div>

</body>
</html>

我的目录结构,

templates
  |
   ------> index.html
application.py
requirments.txt

但是当我不使用 render_template 时,我没有发现任何问题,这是代码,

from flask import Flask, render_template
import requests

application = Flask(__name__, template_folder="templates", static_folder="static")

@application.route("/")
def index():
    return "Hello Flask!!"

# run the app.
if __name__ == "__main__":
    application.debug = True
    application.run()

提前致谢。

编辑 -

我能够解决这个问题,问题出在我创建的 zip 文件夹上。一旦我创建了一个合适的 zip 并将其上传到 aws beanstalk,它就开始工作了。