本文整理匯總了Python中wheezy.http.HTTPResponse.headers[0]方法的典型用法代碼示例。如果您正苦於以下問題:Python HTTPResponse.headers[0]方法的具體用法?Python HTTPResponse.headers[0]怎麽用?Python HTTPResponse.headers[0]使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類wheezy.http.HTTPResponse
的用法示例。
在下文中一共展示了HTTPResponse.headers[0]方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: get
# 需要導入模塊: from wheezy.http import HTTPResponse [as 別名]
# 或者: from wheezy.http.HTTPResponse import headers[0] [as 別名]
def get(self):
con = session()
repo = Repository(con)
CONTENT_TYPE_XML='text/xml'
CONTENT_TYPE_XML_RSP=CONTENT_TYPE_XML+'; charset=utf-8'
if DEBUG:
base_url = 'http://192.168.72.100:8080'
else:
base_url = 'http://shoboi.net'
feed = feedgenerator.Atom1Feed(
title = 'しょぼいろだ。',
link = 'http://shobi.net/',
feed_url = 'http://shoboi.net/atom',
description = u'エロも笑いも虹も慘事もしょぼいろだで共有してね',
author_name=u'しょぼい。',
language = u"ja",
pubdate = datetime.utcnow()
)
upimages = repo.list_upimages()
for idx, i in enumerate(upimages):
feed.add_item(
title = i.title or 'タイトルなし',
link = '%s/detail/%s' % (base_url, i.id),
description = """<![CDATA[
<a href="%s/detail/%s">
<img src="%s/img/%s">
</a>
]]>""" % (base_url, i.id, base_url, i.thumb),
author_name = i.author or '名無し',
pubdate = datetime.now()
)
if idx >= 4: # 5件まで
break;
response = HTTPResponse()
content_type = ('Content-Type', CONTENT_TYPE_XML_RSP)
response.headers[0] = content_type
response.write(feed.writeString('utf-8'))
response.cache_dependency = ('d_atom', )
return response