2017-08-29 52 views
0

我正在通过一个python金字塔教程,我一直在尽可能多的笔记,因为我可以在我写的文件内。腐败的开发.ini代码

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

我编写了像教程中所做的那样的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铬回报:

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

注:

  • 我使用PyCharm作为我的IDE
  • 我在我的本地计算机上运行该代码

回答

1

ERR_CONNECTION_REFUSED意味着你在Chrome的地址栏输入的端口不与您的.ini文件中的端口号配置对齐。仔细查看您的端口号以确保它们对齐。您将43转换为您的原始.iniport = 6534),因此我假设您尝试在Chrome的地址栏中访问http://0.0.0.0:6543

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

+0

哇!这是一个很棒的提示,完全让这个尴尬的问题值得。 –