本文整理汇总了Python中models.Log.query方法的典型用法代码示例。如果您正苦于以下问题:Python Log.query方法的具体用法?Python Log.query怎么用?Python Log.query使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类models.Log
的用法示例。
在下文中一共展示了Log.query方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: get
# 需要导入模块: from models import Log [as 别名]
# 或者: from models.Log import query [as 别名]
def get(self):
# get user ip
if self.request.remote_addr:
# query geo-location of IP
query_args = { 'token' : 'dWEF43tHwFfgG51ASeFg5087rtRBR', 'ip' : self.request.remote_addr }
encoded_args = urllib.urlencode(query_args)
url = 'http://52.34.94.166:3000/get_ip_geo'
result = json.loads(urllib2.urlopen(url, encoded_args).read())
print result
lat_lng = result['geo']['ll']
# store data
custom_index_log.ip_address = self.request.remote_addr
custom_index_log.lat = lat_lng[0].__str__()
custom_index_log.lng = lat_lng[1].__str__()
custom_index_log.put()
# set template
template = JINJA_ENVIRONMENT.get_template('index.html')
# get ip addresses of visitors
ip_logs = Log.query().order(-Log.access_time)
# values to pass to front-end
template_values = { 'title' : 'Bay Technology',
'greeting' : 'Hello Bay Tecnology',
'ip_logs' : ip_logs}
# dispatch template and values to front-end
self.response.write(template.render(template_values))
示例2: get
# 需要导入模块: from models import Log [as 别名]
# 或者: from models.Log import query [as 别名]
def get():
"""
Log the post-call data
"""
call_sid = self.request.get('CallSid')
call = Log.query(Log.call_sid==call_sid).fetch()
if call:
call_duration = self.request.get('DialCallDuration')
start_time = self.request.get('StartTime')
end_time = self.request.get('EndTime')
call.put()
示例3: get
# 需要导入模块: from models import Log [as 别名]
# 或者: from models.Log import query [as 别名]
def get(self):
# set template
template = JINJA_ENVIRONMENT.get_template('index.html')
# get ip addresses of visitors
ip_logs = Log.query().order(-Log.access_time)
# values to pass to front-end
template_values = { 'title' : 'COEN296 IoT',
'greeting' : 'Door Alarm Demo',
'ip_logs' : ip_logs}
# dispatch template and values to front-end
self.response.write(template.render(template_values))
示例4: logs
# 需要导入模块: from models import Log [as 别名]
# 或者: from models.Log import query [as 别名]
def logs(req):
"""
Creates an entity in the log
:param req:
:return: 201, and the log object
"""
if req.method == 'GET':
logs = Log.query().fetch(1)
return logs[0]
else:
try:
j_req = json.loads(req.body)
except (TypeError, ValueError) as e:
raise BadRequest("Invalid JSON")
log = Log()
log.data = j_req
log.put()
return 201, log.data
示例5: get
# 需要导入模块: from models import Log [as 别名]
# 或者: from models.Log import query [as 别名]
def get(self, namespace):
logs = Log.query(namespace=namespace).order(-Log.created_at)
self.render_template('logs.html', logs=logs, namespace=namespace)