[英]How to get the serving host and port in python pyramid application?
I am trying to get the serving host and port of a pyramid applications using: 我正在尝试使用以下方法获取金字塔应用程序的服务主机和端口:
settings = get_current_registry().settings
But how can I get the host? 但是我怎样才能获得主持人?
I tried: 我试过了:
settings.get('host')
But I am getting None
但是我得到了
None
Any help is much appreciated. 任何帮助深表感谢。
request.host or request.host_url
By default python pyramid use pserve and you can run pyramid by using mod_wsgi and uwsgi 默认情况下,蟒蛇金字塔使用pserve,你可以使用mod_wsgi的和uwsgi运行金字塔
Pyramid serving host and port exist in development.ini and production.ini file 金字塔服务主机和端口存在于development.ini和production.ini文件中
For pserve: 对于pserve:
[server:main]
use = egg:waitress#main
host = 0.0.0.0
port = 6543
For Uwsgi: 对于Uwsgi:
[uwsgi]
http = :9090
paste = config:project_url/test/development.ini**(set your directory)**
master = true
processes = 4
threads = 2
you can change this port 你可以改变这个端口
running command: 运行命令:
pserve development.ini
uwsgi development.ini
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.