【问题标题】:corrupt development.ini code损坏的 development.ini 代码
【发布时间】:2017-08-30 03:56:33
【问题描述】:

我正在完成一个 python 金字塔教程,并且我一直在我正在编写的文件中做尽可能多的笔记。

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

我像在教程中那样编写了 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

运行 pserve development.ini chrome 返回:

This site can’t be reached

0.0.0.0 refused to connect.
Search Google for 6543
ERR_CONNECTION_REFUSED

我删除了 cmets:

[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 文件。

注意:

  • 我正在使用 PyCharm 作为我的 ide
  • 我正在本地计算机上运行此代码

【问题讨论】:

    标签: python-3.x pycharm pyramid


    【解决方案1】:

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

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

    【讨论】:

    • 哇!这是一个很棒的提示,完全值得这个令人尴尬的问题。
    猜你喜欢
    • 1970-01-01
    • 2014-09-04
    • 2017-02-23
    • 1970-01-01
    • 2012-12-08
    • 1970-01-01
    • 2021-06-14
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多