def view_input(self):
"""
Returns the input_file of testcase
specified in GET request
"""
try:
id = int(self.get_argument('id'))
session = self.acquire_sql_session()
try:
testcase = TestcaseRepository.get_by_id(session, id)
except SQLAlchemyError:
raise HTTPError(400, 'Testcase with specified '
'id does not exist.')
except MissingArgumentError:
raise HTTPError(404, 'No id specified.')
except HTTPError:
raise
except SQLAlchemyError:
raise HTTPError(500, 'Database error, could not '
'find specified id.')
except:
raise HTTPError(500, 'Unexpected error')
# Sends the actual file data
self.write(testcase.input_file)
session.close()
评论列表
文章目录