python - render_template 在 aws beanstalk 中给出内部服务器错误
问题描述
我正在尝试在 AWS elasticbeanstalk 中托管一个简单的应用程序,但是当我使用 render_template 它给我这个错误“内部服务器错误服务器遇到内部错误并且无法完成您的请求。服务器过载或存在应用程序中的错误。”
这是我的烧瓶代码,
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,它就开始工作了。
推荐阅读
- javascript - 将数组对象转换为数组值
- docker - 如何在elasticsearch中重新索引和清除集群中的数据
- javascript - 通过获取当前网页 URL 来修改内容
- visual-studio-2019 - Microsoft Visual Studio 2019 在哪里存储“不再询问”答案?
- postgresql - 无法创建请求的服务(Hibernate + JPA)
- node.js - NestJS 是否使用 NODE_ENV?建议设置吗?
- c# - .Netcore Api Postman 500 内部服务器错误
- python - Jupyter 实验室中的子图
- casting - 将 DOUBLE PRECISION 转换为 VARCHAR 后出现尾随零
- ios - 由于在 11.3 以上的 Xcode 版本中使用本地 var 变量进行优化,导致 iOS 应用程序崩溃