python 瓶 : Can't connect to server or debug it

标签 python logging server httprequest httpresponse

当我尝试运行此示例中的服务器时,我可以看到它在正确的端口上运行。但是,无法从外部访问它(内部服务器错误),也无法通过常见方法在控制台中对其进行调试(看不到任何输出)。

我确定端口可用并且服务器正在运行。如何修复或调试这个问题?

from bottle import run, post, request, response, get, route

@route('/<path>', method = 'GET')
def process(path):
    response.content_type = 'text/html'
    return 'Hello World GET'

@route('/<path>', method = 'POST')
def process(path):
    response.content_type = 'text/html'
    return 'Hello World POST'

run(host='localhost', port=8000, debug=True)

最佳答案

造成此问题的原因是设置 host='localhost',这使得服务器无法从外部访问,我只能使用 localhost 进行访问。将声明更改为 host='0.0.0.0' 解决了我的问题。

关于 python 瓶 : Can't connect to server or debug it,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33674665/

相关文章:

server - 子域已创建但运行不正常

security - 如何跟踪 ubuntu 服务器上的恶意软件来源并阻止它

python - Python中global关键字的使用

python - lxml Python包将版权符号更改为HTML实体

python - 匹配包含月份的日期范围的正则表达式

linux - apache日志中没有IP地址

logging - 如何调试logstash文件插件

python - 使用 quiver() 绘制风矢量

logging - 记录企业应用程序的最佳实践是什么?

c++ - 客户端服务器 C++ 序列化