예제 #1
0
파일: static.py 프로젝트: pavlovdog/core4
 def get_content(cls,
                 abspath: str,
                 start: int = None,
                 end: int = None) -> Generator[bytes, None, None]:
     if abspath != "":
         return StaticFileHandler.get_content(abspath, start, end)
     return
예제 #2
0
파일: default.py 프로젝트: flashhtml5/PyF5
 def get_content(cls, abspath, start=None, end=None):
     if cls.is_html_path(abspath):
         html = open(abspath, 'r').read()
         html = html.replace('</body>', cls.SCRIPT_AND_END_OF_BODY)
         return html
     else:
         return StaticFileHandler.get_content(abspath, start, end)
예제 #3
0
def get_upload_content(filename):

    upload_path = get_upload_path()

    filepath = os.path.join(upload_path, filename)
    filepath = validate_absolute_path(filepath)

    return StaticFileHandler.get_content(filepath)
예제 #4
0
파일: static.py 프로젝트: no2key/PyF5
 def get_content(cls, abspath, start=None, end=None):
     gc.collect()  # 在mp4内容的时候,如果刷新网页会导致10053错误,并且内存不能回收,这里粗暴处理一下
     if cls.is_html_path(abspath):
         html = open(abspath, 'r').read()
         html = html.replace('</body>', cls.SCRIPT_AND_END_OF_BODY)
         return html
     else:
         return StaticFileHandler.get_content(abspath, start, end)
예제 #5
0
파일: static.py 프로젝트: Ju2ender/PyF5
 def get_content(cls, abspath, start=None, end=None):
     gc.collect()  # 在mp4内容的时候,如果刷新网页会导致10053错误,并且内存不能回收,这里粗暴处理一下
     _, ext = os.path.splitext(abspath)
     if ext in SPECIAL_EXTENSIONS:
         content = open(abspath, 'r').read()
         if ext in HTML_EXTENSIONS:
             return process_html(content)
         elif ext in CSS_EXTENSIONS:
             return process_css(content)
     return StaticFileHandler.get_content(abspath, start, end)
예제 #6
0
 def get_content(cls, abspath, start=None, end=None):
     gc.collect()  # 在mp4内容的时候,如果刷新网页会导致10053错误,并且内存不能回收,这里粗暴处理一下
     _, ext = os.path.splitext(abspath)
     if ext in SPECIAL_EXTENSIONS:
         content = open(abspath, 'r').read()
         if ext in HTML_EXTENSIONS:
             return process_html(content)
         elif ext in CSS_EXTENSIONS:
             return process_css(content)
     return StaticFileHandler.get_content(abspath, start, end)
예제 #7
0
 def create_static_file_handler(self, name, path):
     self.set_header("Content-Type", "application/octet-stream")
     self.set_header("Content-Disposition",
                     "attachment; filename={}".format(name))
     content = StaticFileHandler.get_content(path)
     if isinstance(content, bytes):
         content = [content]
     for chunk in content:
         try:
             self.write(chunk)
             yield self.flush()
         except iostream.StreamClosedError:
             self.write_error(500, desc="download file failed, retry")
             return
     self.set_status(200)
     return self.finish()