最近,Pycharm升级到2018版,没想到遇到大坑。
在编写Flask项目时,Debug=True后,代码调试模式无法开启。然后,尝试绑定 PORT=8888,也不能成功。
Pycharm的Debug模式必须在又上角 运行按钮 左侧 的下拉栏中 选择 Edit Config...,在其中手动勾选 Debug Mode。
其后,我尝试寻找HOST和PORT设置的相关选项,但是无果。
经过在中外论坛的一番查找发现根本没有相关的问题和解决方案,最后在Pycharm2018的官方文档中找到的答案。
Additional options | Parameters of the flask run command.
Example: |
大概的意思就是 你需要在 Additinal options栏 中:手动写入 --host=127.0.0.2 --port=1234。
我不太能理解JetBrains的设计,选项既不显眼,用户还得在代码中写明config的配置用于生产环境。哎
希望能帮到遇到同样问题的程序猿们。