本文整理汇总了Python中utility.Utility.ins方法的典型用法代码示例。如果您正苦于以下问题:Python Utility.ins方法的具体用法?Python Utility.ins怎么用?Python Utility.ins使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类utility.Utility
的用法示例。
在下文中一共展示了Utility.ins方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: main_handler
# 需要导入模块: from utility import Utility [as 别名]
# 或者: from utility.Utility import ins [as 别名]
def main_handler():
response.content_type = 'application/json'
return {
'status': 'OK',
'detail': 'Nothing to show on this page, try http://%s:%s/login'
% (Utility.ins().hostname(), Utility.ins().port())
}
示例2: event_list_handler
# 需要导入模块: from utility import Utility [as 别名]
# 或者: from utility.Utility import ins [as 别名]
def event_list_handler():
user_id = request.query.user
credentials = OAuthHandler.ins().get_credentials(user_id)
if credentials is None or credentials.invalid:
return {
'status': 'ERROR',
'detail': 'User id not exist, URL should look like: http://%s:%s/event/list?user=123'
% (Utility.ins().hostname(), Utility.ins().port())
}
try:
calendar_output = get_calendar_data(credentials)
response.set_header('Cache-Control', 'no-cache')
response.set_header('Content-type', 'application/json')
return calendar_output
except AccessTokenRefreshError:
response.content_type = 'application/json'
return {
'status': 'ERROR',
'detail': 'Credential expired, please re-login'
}
示例3: login_handler
# 需要导入模块: from utility import Utility [as 别名]
# 或者: from utility.Utility import ins [as 别名]
def login_handler():
user_id = request.query.user
print('>> Login using: ' + user_id)
if user_id:
credentials = OAuthHandler.ins().get_credentials(user_id)
if credentials is None or credentials.invalid:
OAuthHandler.ins().respond_redirect_to_auth_server(response, user_id)
else:
response.content_type = 'application/json'
return {
'status': 'OK',
'detail': 'Already logined'
}
else:
response.content_type = 'application/json'
return {
'status': 'ERROR',
'detail': 'Missing user id, URL should look like: http://%s:%s/login?user=123'
% (Utility.ins().hostname(), Utility.ins().port())
}
示例4: run
# 需要导入模块: from utility import Utility [as 别名]
# 或者: from utility.Utility import ins [as 别名]
#!/usr/bin/env python
import sys, os
from bottle import run
from utility import Utility
sys.path.append(os.sep.join((os.getcwd(),'handler')))
import root
import login
import event
import gettime
hostname = Utility.ins().hostname()
if hostname != '':
run(host=hostname, port=9999, debug=True)
else:
print(">> ERROR: client_secrets.json file incorrect!")