本文整理汇总了Python中httphandler.Response类的典型用法代码示例。如果您正苦于以下问题:Python Response类的具体用法?Python Response怎么用?Python Response使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Response类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: listurl
def listurl(_request):
res = Response()
rsslist = Rssurl.select()
t = SimpleTemplate(file_path=relativepath('urllist.html'))
body = t.render({'rsslist': rsslist})
res.set_body(body)
return res
示例2: index
def index(_request, d ={'counter':0}):
body = """<html><body><p>${counter}</p></body></html>"""
res = Response()
t = SImpleTemplate(body)
body = t.render(d)
d['counter'] += 1
res.set_body(body)
return res
示例3: get_add_form
def get_add_form(values={}, errors={}):
res = Response()
t = SimpleTemplate(file_path=relativepath('form.html'))
body = t.render({'message': 'RSS巡回用URLの追加',
'form': addform,
'values': values, 'errors': errors})
res.set_body(body)
return res
示例4: index
def index(_request, d={'counter': '0'}):
body = """<html><body><p>${counter}</p></body></html>"""
res = Response()
t = SimpleTemplate(body)
body = t.render(d)
d['counter'] = str(int(d['counter']) + 1)
res.set_body(body)
return res
示例5: index
def index(_request, foo='', d={'counter': '0'}):
body = base_body % ('<p>Logged in!</p>')
res = Response()
t = SimpleTemplate(body)
body = t.render(d)
d['counter'] = str(int(d['counter']) + 1)
res.set_body(body)
return res
示例6: login_form
def login_form(_request, values={}, errors={}):
body = base_body % ('${form.display(values, errors)}')
res = Response()
t = SimpleTemplate(body)
values['password'] = ''
body = t.render({'form': loginform, 'values': values, 'errors': errors})
res.set_body(body)
return res
示例7: logout
def logout(_request):
body=get_htmltemplate() % ('<p>Logged out</p>')
res=Response()
c=SimpleCookie()
c['authhash']=''
res.set_header(*c.output().split(': '))
res.set_body(body)
return res
示例8: login_form
def login_form(_request, values={}, errors={}):
res=Response()
t=SimpleTemplate(file_path=relativepath('form.html'))
values['password']=''
body=t.render({'form':loginform, 'values':values, 'errors':errors,
'message':u'ログイン'})
res.set_body(body)
return res
示例9: add
def add(_request, title='', url=''):
res = Response()
values, errors = addform.validate({'title': title, 'url': url})
if [ x for x in Rssurl.select(url=url)]:
errors['url'] = "このURLは登録済みです"
if errors:
return get_add_form(values, errors)
Rssurl(title=title, url=url)
t = SimpleTemplate(file_path=relativepath('posted.html'))
body = t.render({'message': '巡回用URLを追加しました'})
res.set_body(body)
return res
示例10: get_edit_form
def get_edit_form(item_id, values={}, errors={}):
res = Response()
t = SimpleTemplate(file_path=relativepath('form.html'))
if not values:
for item in Rssurl.select(id=item_id):
pass
values = {'item_id': item_id, 'title':item.title, 'url': item.url}
body = t.render({'message': 'RSS巡回用URLの編集',
'form': editform,
'values': values, 'errors': errors})
res.set_body(body)
return res
示例11: edit
def edit(_request, item_id, title='', url=''):
res=Response()
values, errors=editform.validate({'item_id':item_id,
'title':title, 'url':url})
if errors:
return get_edit_form(item_id, values, errors)
for item in Rssurl.select(id=item_id):
item.title=title
item.url=url
t=SimpleTemplate(file_path=relativepath('posted.html'))
body=t.render({'message': u'巡回用URLを編集しました'})
res.set_body(body)
return res
示例12: index
def index(_request):
rsslist = []
try:
for rss in Rssurl.select(order_by='id'):
rsslist.extend(parse_rss(rss.url))
except:
pass
res = Response()
p = path.join(path.dirname(__file__), 'rsslist.html')
t = SimpleTemplate(file_path=p)
body = t.render({'rsslist': rsslist})
res.set_body(body)
return res
示例13: login
def login(_request, username='', password=''):
res = Response()
values, errors = loginform.validate({'username': username,
'password': password})
if errors or fixeduser != username or fixedpass != password:
return login_form(_request, values, errors)
c = SimpleCookie()
m = hashlib.md5((username+':'+password).encode('utf-8'))
c['authhash'] = m.hexdigest()
c['authhash']['expires'] = 'Thu, 1-Jan-2030 00:00:00 GMT'
res.set_header(*c.output().split(': '))
res.status = 302
res.set_header('Location', '/')
res.set_body('')
return res
示例14: wrapper
def wrapper(_request, *args, **kws):
if self.checkfunc(_request):
return func(_request=_request, *args, **kws)
else:
res=Response()
res.status=302
res.set_header('Location', self.loginpath)
res.set_body('')
return res
示例15: index
def index(_request, name='', body='', submit=''):
res=Response()
t=SimpleTemplate(htmlbody)
body=t.render({'name':name, 'body':body})
res.set_body(body)
return res