【问题标题】:Python Bottle website visible over network?Python Bottle 网站在网络上可见?
【发布时间】:2016-04-05 00:23:12
【问题描述】:

有没有办法让我的网站可以通过我连接的网络访问?

from bottle import route, run, template

@route('/hello/<name>')
def index(name):
    return template('<b>Hello {{name}}</b>!', name=name)

run(host='localhost', port=8080)

【问题讨论】:

标签: python web network-programming bottle


【解决方案1】:

正如 cmets 中的@fukanchik 解释的那样,您必须在运行命令中使用host='0.0.0.0' 才能让bottle 侦听系统中所有可用的ip。

from bottle import route, run, template

@route('/hello/<name>')
def index(name):
    return template('<b>Hello {{name}}</b>!', name=name)

run(host='0.0.0.0', port=8080)

更多信息可以查看这个问题:whats the difference between ip address 0.0.0.0 and 127.0.0.1

【讨论】:

    猜你喜欢
    • 2012-11-15
    • 2016-05-16
    • 1970-01-01
    • 1970-01-01
    • 2015-09-04
    • 1970-01-01
    • 2017-01-01
    • 2012-03-31
    • 1970-01-01
    相关资源
    最近更新 更多