V2EX = way to explore
V2EX 是一个关于分享和探索的地方
Sign Up Now
For Existing Member  Sign In
推荐学习书目
Learn Python the Hard Way
Python Sites
PyPI - Python Package Index
http://diveintopython.org/toc/index.html
Pocoo
值得关注的项目
PyPy
Celery
Jinja2
Read the Docs
gevent
pyenv
virtualenv
Stackless Python
Beautiful Soup
结巴中文分词
Green Unicorn
Sentry
Shovel
Pyflakes
pytest
Python 编程
pep8 Checker
Styles
PEP 8
Google Python Style Guide
Code Style from The Hitchhiker's Guide
imften
V2EX  ›  Python

请教各位大大:Google App Engine上Python获取URL中的域名的问题。

  •  
  •   imften · Aug 15, 2010 · 7253 views
    This topic created in 5738 days ago, the information mentioned may be changed or developed.
    新人,现在是因为Google App Engine才学习Python,实在不熟悉Python系统对象。

    故此有疑问请教各位大大:

    假设我的应用可以通过aaa.com和bbb.com这2个域名访问(即:绑定了2个域名),

    我该怎么获取当前域名(就是用户当前访问的是哪个域名)?
    5 replies    1970-01-01 08:00:00 +08:00
    Livid
        1
    Livid  
    MOD
    PRO
       Aug 15, 2010 via iPhone
    self.request.headers['Host']
    imften
        2
    imften  
    OP
       Aug 15, 2010
    唉,原来这样。这个想搜索都搜索不到。谢谢啦。

    不过,这个,还包含了端口,只取域名呢?(或者,我分割一下吧)
    imften
        3
    imften  
    OP
       Aug 15, 2010
    @Livid 有没有request对象详解的发给我学习一下?
    imften
        5
    imften  
    OP
       Aug 15, 2010
    @sospartan 嗯,嗯,谢谢。我也在看手册,只是还没看到这里,呵呵。
    查继承自 WebOb Request 的实例变量,找到了:request.environ['SERVER_NAME']
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   786 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 45ms · UTC 20:40 · PVG 04:40 · LAX 13:40 · JFK 16:40
    ♥ Do have faith in what you're doing.