损坏 development.ini 代码

corrupt development.ini code

我正在学习 python 金字塔教程,并且我在我正在编写的文件中做了尽可能多的笔记 ide。

发生了奇怪的事情,我想知道为什么。

我按照教程中的方式编写了 development.ini 文件,然后添加了注释。

# we are using this file for configureation in development

# config our wsgi
[app:main]
# which entry point to use as the app
use = egg:mysite
# reloads when templates are changed, not to be used in production
pyramid.reload_templates = true

#which server to use
[server:main]
#get the main entry point from the waitress package
use = egg:waitress#main
host = 0.0.0.0
port = 6534

# this is a great way to remove code for the rest of our package
# more importantly this file is easy to tweak for launching our package in a different manner

运行 保存 development.ini chrome returns:

This site can’t be reached

0.0.0.0 refused to connect.
Search Google for 6543
ERR_CONNECTION_REFUSED

我删除评论:

[app:main]
use = egg:mysite
pyramid.reload_templates = true

[server:main]
use = egg:waitress#main
host = 0.0.0.0
port = 6534

我收到和以前一样的错误。

This site can’t be reached

0.0.0.0 refused to connect.
Search Google for 6543
ERR_CONNECTION_REFUSED

然后我将教程存储库中的代码复制并粘贴到 development.ini:

[app:main]
use = egg:mysite
pyramid.reload_templates = true

[server:main]
use = egg:waitress#main
host = 0.0.0.0
port = 6543

我成功连接到了本地主机。


我最想知道为什么会这样,如何避免这个问题,如果可能的话如何评论 development.ini 文件。

注:

ERR_CONNECTION_REFUSED表示您在Chrome的地址栏中输入的端口与您在.ini文件中配置的端口号不一致。仔细查看您的端口号以确保它们对齐。您调换了原始 .ini (port = 6534) 中的 43,所以我假设您试图在 Chrome 中达到 http://0.0.0.0:6543地址栏。

额外提示:PyCharm 允许您比较单个文件在磁盘上的历史记录以及版本控制。这有助于揭示印刷错误。 Right/CTRL-click 在文件上,本地历史 > 显示历史