comments = []@app.route("/", methods=["GET", "POST"])def index():
if request.method == "GET":
return render_template("index.html", comments=comments)
#如果是post:
comments.append(request.form["contents"])
return redirect(url_for('index'))場(chǎng)景還原:我的服務(wù)器沒開80端口,我用nginxlisten 81端口。利用flask框架(上述代碼)遇到url_for('index')定向到 xxx.cn??墒俏倚枰ㄏ虻?xxx.cn:81,那么應(yīng)該怎么寫?(手動(dòng)訪問xxx.cn:81都是可以的。)我的Nginx配置server {
listen 81;
server_name 11.11.11.11;
location / {
proxy_pass http://127.0.0.1:5000; # 這里是指向 gunicorn host 的服務(wù)地址 proxy_set_header Host $host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
}
添加回答
舉報(bào)
0/150
提交
取消