【发布时间】:2020-07-10 16:52:25
【问题描述】:
我正在尝试部署我的烧瓶应用程序,以便它可以在我的局域网中的任何计算机上使用。但是,当我执行它时,我在 apache2 error.log 文件中收到以下错误:
这是为__init__.py(python3):
from flask import Flask, redirect, url_for, render_template,request
app = Flask('__name__')
@app.route("/", methods=["POST", "GET"])
def home():
if request.method == "POST":
return render_template("index.html")
else:
return render_template("index2.html")
if __name__ == "__main__":
app.run()
而我的代码 index.html 是:
<!DOCTYPE html>
<html>
<head></head>
<body>
<h1>Home Page</h1>
<form action="#" method="post">
<input type="submit" name="submit">
</form>
</body>
</html>
对于 index2.html,它与 index.html 的代码相同,只是标签 h1 具有不同的内容。
当我在本地 (http://127.0.0.1:5000/) 执行此操作时,它工作正常。
我正在关注本教程:https://www.youtube.com/watch?v=YFBRVJPhDGY
知道我可能做错了什么吗?
【问题讨论】:
-
你能分享你的项目结构吗?
-
@sahasrara62 你是什么意思?我把文件的结构放了
-
您使用的是
from cloud import app之类的东西吗?如果不是,则将__init__.py更改为myapp.py并在app=flask(__name__, template_folder="../tmplates") -
是的 @sahasrara62 我在我的 .wsgi 文件中使用从云导入应用程序
-
只需在 'app=flask(template folder)' 中添加模板文件夹路径
标签: python html python-3.x flask