码迷,mamicode.com
首页 > Web开发 > 详细

flask url_for后没有带端口号

时间:2019-11-21 14:23:51      阅读:114      评论:0      收藏:0      [点我收藏+]

标签:tail   步骤   指定   lan   代码   str   运行   nbsp   strong   

问题描述:

在本地运行flask项目,当运行到下面这句代码时,正常重定向

        return redirect(url_for(.script_case))

但项目布署到服务器之后,代码运行一这句话,却报了404 Not Found

 

问题分析:

  仔细看了url是没有端口号.

  正确的地址:

http://10.2.1.92:8001/script_case

  实际请求的地址:

10.2.1.92/script_case

 

解决步骤 :

  查找nginx配置文件

[root@67 ~]# find  / -name nginx.conf
/etc/nginx/nginx.conf

  编辑nginx配置文件

nano /etc/nginx/nginx.conf

  指定nginx运行的端口号

 技术图片

    测试 修改

sudo nginx -t
nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
nginx: configuration file /etc/nginx/nginx.conf test is successful

  重启nginx服务

systemctl restart nginx.service

 

 

 

参考文档:

 

flask url_for 图片URL 缺少端口号

 

flask url_for后没有带端口号

标签:tail   步骤   指定   lan   代码   str   运行   nbsp   strong   

原文地址:https://www.cnblogs.com/kaerxifa/p/11904835.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!