Skip to content

Instantly share code, notes, and snippets.



Created Aug 29, 2017
What would you like to do?
import json, urllib
import tornado.web
import tornado.gen
from datetime import date, timedelta
from tornado.httpclient import AsyncHTTPClient, HTTPRequest
class NewNewHandler(tornado.web.RequestHandler):
def post(self):
ret = { 'code': 200, 'content': '' }
campus_id = self.get_argument('campusId', default='22')
date = self.get_argument('date')
building_id = self.get_argument('buildingId')
start_sequence = self.get_argument('startSequence')
end_sequence = self.get_argument('endSequence')
page = self.get_argument('page')
page_size = self.get_argument('pageSize', default='20')
client = AsyncHTTPClient()
request = HTTPRequest('' + date)
response = yield tornado.gen.Task(client.fetch, request)
date_info = json.loads(response.body)
request = HTTPRequest('',
'pageNo': page,
'pageSize': page_size,
'campusId': campus_id,
'buildingId': building_id,
'startWeek': date_info['week'],
'endWeek': date_info['week'],
'dayOfWeek': date_info['dayOfWeek'],
'startSequence': start_sequence,
'endSequence': end_sequence,
'termId': date_info['termId']
response = yield tornado.gen.Task(client.fetch, request)
ret['content'] = json.loads(response.body)
except Exception,e:
ret['code'] = 500
ret['content'] = u'系统错误'
self.write(json.dumps(ret,ensure_ascii=False, indent=2))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.