diff --git a/serve.py b/serve.py index 6921ed1..ac850c1 100755 --- a/serve.py +++ b/serve.py @@ -169,54 +169,6 @@ class FileHandler(BaseHandler): await self.flush() - - -# class FileHandler(BaseHandler): -# SUPPORTED_METHODS = ['GET'] -# chunk_size = 512 * 1024 # serve up to 512 KiB multiple times - -# @tornado.web.authenticated -# async def get(self): -# uid = self.current_user -# ref = self.get_query_argument('ref', None) -# image = self.get_query_argument('image', None) - -# # FIXME does not work when user 0 is reviewing a test - -# t = self.testapp.get_student_test(uid) -# if t is not None: -# for q in t['questions']: -# if q['ref'] == ref: -# filepath = path.join(q['path'], 'public', image) - -# try: -# f = open(filepath, 'rb') -# except FileNotFoundError: -# logging.error(f'File not found: {filepath}') -# except PermissionError: -# logging.error(f'No permission: {filepath}') -# else: -# content_type = mimetypes.guess_type(image) -# self.set_header("Content-Type", content_type[0]) - -# # divide the file into chunks and write one chunk at a time, so -# # that the write does not block the ioloop for very long. -# with f: -# chunk = f.read(self.chunk_size) -# while chunk: -# try: -# self.write(chunk) # write the cunk to response -# await self.flush() # flush the current chunk to socket -# except iostream.StreamClosedError: -# break # client closed the connection -# finally: -# del chunk -# await asyncio.sleep(0) -# chunk = f.read(self.chunk_size) - -# raise tornado.web.HTTPError(status_code=404) # Not Found - - # ------------------------------------------------------------------------- # Test shown to students # ------------------------------------------------------------------------- @@ -243,7 +195,6 @@ class TestHandler(BaseHandler): @tornado.web.authenticated async def get(self): uid = self.current_user - print(uid) t = self.testapp.get_student_test(uid) # reload page returns same test if t is None: t = await self.testapp.generate_test(uid) -- libgit2 0.21.2