本文整理匯總了Python中urls.urls方法的典型用法代碼示例。如果您正苦於以下問題:Python urls.urls方法的具體用法?Python urls.urls怎麽用?Python urls.urls使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類urls
的用法示例。
在下文中一共展示了urls.urls方法的10個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: get_access_token
# 需要導入模塊: import urls [as 別名]
# 或者: from urls import urls [as 別名]
def get_access_token(self):
"""
??access_token:{"access_token":"ACCESS_TOKEN","expires_in":7200}
@return:
"""
url = urls['access_token_request_url']
app_id = self.app_id
app_secret = self.app_secret
grant_type = 'client_credential'
request_url = url + '?grant_type=%s&appid=%s&secret=%s' % (grant_type, app_id, app_secret)
try:
request = urllib2.urlopen(request_url)
response = request.read()
result = json.loads(response)
if result.get('access_token', False):
return {'success': True, 'result': result}
else:
return {'success': False, 'msg': str(result)}
except Exception as e:
_logger.error(e.message)
return {'success': False, 'msg': e.message}
示例2: create_media
# 需要導入模塊: import urls [as 別名]
# 或者: from urls import urls [as 別名]
def create_media(self):
"""
???????????
@return:
"""
url = urls['upload_media_url'] + '?access_token=%s' % self.official_account_id.access_token
data = dict()
data['articles'] = []
article = dict()
article['title'] = self.title
article['thumb_media_id'] = self.thumb_media_id
article['author'] = self.author
article['digest'] = self.digest
article['show_cover_pic'] = self.show_cover_pic
article['content'] = self.content
article['content_source_url'] = self.content_source_url
data['articles'].append(article)
res = requests.request('post', url, data=json.dumps(data))
result = res.json()
self.media_id = result['media_id']
示例3: __init__
# 需要導入模塊: import urls [as 別名]
# 或者: from urls import urls [as 別名]
def __init__(self):
print '\ninside Application __init__()'
tornado.web.Application.__init__(self, urls, **settings)
print 'Aapplication __init__ caleed with web.Application()'
print 'returning from Application __init__'
示例4: __init__
# 需要導入模塊: import urls [as 別名]
# 或者: from urls import urls [as 別名]
def __init__(self):
tornado.web.Application.__init__(self, urls, **settings)
示例5: start
# 需要導入模塊: import urls [as 別名]
# 或者: from urls import urls [as 別名]
def start():
global application, server, ioloop
application = Applicaton(urls, debug=setting.DEBUG, autoreload=setting.AUTORELOAD)
server = HTTPServer(application)
server.bind(5000)
server.start()
ioloop = IOLoop.instance()
ioloop.add_callback(run)
ioloop.add_callback(fetch_title)
ioloop.add_callback(application.start)
ioloop.start()
示例6: create_menu
# 需要導入模塊: import urls [as 別名]
# 或者: from urls import urls [as 別名]
def create_menu(self):
"""
???????,??post,????????????????json??,??????????
@return:
"""
url = urls['menu_request_url']
request_url = url + '?access_token=%s' % self.official_account_id.access_token
post_data = self.parse_to_json_data()
params = {'data': post_data.encode('utf-8')}
res = requests.request('post', request_url, **params)
return res.json()
示例7: search_menu
# 需要導入模塊: import urls [as 別名]
# 或者: from urls import urls [as 別名]
def search_menu(self):
"""
??????????,??????????
@return:
"""
url = urls['menu_request_url']
request_url = url + '?access_token=%s' % self.official_account_id.access_token
res = requests.request('get', request_url)
menus = res.json()
print menus
return menus
示例8: delete_menu
# 需要導入模塊: import urls [as 別名]
# 或者: from urls import urls [as 別名]
def delete_menu(self):
"""
????????,???????
@return:
"""
url = urls['menu_delete_all_url']
request_url = url + '?access_token=%s' % self.official_account_id.access_token
res = requests.request('get', request_url)
result = res.json()
print result
return result
示例9: delete_conditional_menu
# 需要導入模塊: import urls [as 別名]
# 或者: from urls import urls [as 別名]
def delete_conditional_menu(self):
"""
???????
@return:
"""
url = urls['menu_conditional_delete_url']
request_url = url + '?access_token=%s' % self.official_account_id.access_token
res = requests.request('post', request_url)
result = res.json()
print result
return result
示例10: delete_media
# 需要導入模塊: import urls [as 別名]
# 或者: from urls import urls [as 別名]
def delete_media(self):
"""
??????
@return:
"""
url = urls['delete_media_url'] + '?access_token=%s' % self.official_account_id.access_token
data = {'media_id': self.media_id}
res = requests.request('post', url, data=json.dumps(data))
data = res.json()
print data