本文整理汇总了Python中bottle.HTTPResponse.set_cookie方法的典型用法代码示例。如果您正苦于以下问题:Python HTTPResponse.set_cookie方法的具体用法?Python HTTPResponse.set_cookie怎么用?Python HTTPResponse.set_cookie使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类bottle.HTTPResponse
的用法示例。
在下文中一共展示了HTTPResponse.set_cookie方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: dropbox_auth
# 需要导入模块: from bottle import HTTPResponse [as 别名]
# 或者: from bottle.HTTPResponse import set_cookie [as 别名]
def dropbox_auth():
"""
Get Dropbox oatuh tokens
"""
storage = SettingStorage(SETTINGS_FILE)
consumer_key = storage.get('dropbox:consumer_key')
consumer_secret = storage.get('dropbox:consumer_secret')
sess = session.DropboxSession(consumer_key, consumer_secret, 'app_folder')
request_token = sess.obtain_request_token()
callback = "%s://%s/dropbox/auth/callback" % (request.urlparts.scheme, request.urlparts.netloc)
auth_url = sess.build_authorize_url(request_token, callback)
# response.set_cookie('request_token', '&'.join([request_token.key, request_token.secret]))
resp = HTTPResponse("", status=302, Location=auth_url)
resp.set_cookie('request_token', '&'.join([request_token.key, request_token.secret]))
return resp
示例2: set
# 需要导入模块: from bottle import HTTPResponse [as 别名]
# 或者: from bottle.HTTPResponse import set_cookie [as 别名]
def set():
resp = HTTPResponse(status=303)
resp.set_header('Location','/')
resp.set_cookie('account', 'admin', secret='ThisIsSecretKey')
return resp