Pycharm2018设置debug模式与host,port的坑

最近,Pycharm升级到2018版,没想到遇到大坑。

在编写Flask项目时,Debug=True后,代码调试模式无法开启。然后,尝试绑定 PORT=8888,也不能成功。

Pycharm的Debug模式必须在又上角 运行按钮 左侧 的下拉栏中 选择 Edit Config...,在其中手动勾选 Debug Mode。

其后,我尝试寻找HOST和PORT设置的相关选项,但是无果。

经过在中外论坛的一番查找发现根本没有相关的问题和解决方案,最后在Pycharm2018的官方文档中找到的答案。

Additional options Parameters of the flask run command.

--host – the IP address of the web server to run your Flask application on. The default value is '127.0.0.1'. To make your web server externally visible, use the '0.0.0.0' value for this parameter.

--port – the port of the web server. The default value is 5000 or it is the port number set in the SERVER_NAME config variable.

Example:--host=127.0.0.2 --port=1234.

附上官方解释: 点击打开链接


大概的意思就是 你需要在 Additinal options栏 中:手动写入 --host=127.0.0.2 --port=1234。

我不太能理解JetBrains的设计,选项既不显眼,用户还得在代码中写明config的配置用于生产环境。哎

希望能帮到遇到同样问题的程序猿们。



猜你喜欢

转载自blog.csdn.net/weixin_42359693/article/details/80775511