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'))場景還原:我的服務器沒開80端口,我用nginxlisten 81端口。利用flask框架(上述代碼)遇到url_for('index')定向到 xxx.cn。可是我需要定向到 xxx.cn:81,那么應該怎么寫?(手動訪問xxx.cn:81都是可以的。)我的Nginx配置server {
listen 81;
server_name 11.11.11.11;
location / {
proxy_pass http://127.0.0.1:5000; # 這里是指向 gunicorn host 的服務地址 proxy_set_header Host $host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
}
添加回答
舉報
0/150
提交
取消