GNServer 0.0.0.0.8__tar.gz → 0.0.0.0.10__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -30,7 +30,7 @@ DEALINGS IN THE SOFTWARE.
30
30
  """
31
31
 
32
32
  from ._app import App
33
- from KeyisBClient.gn import GNRequest, GNResponse, CORSObject
33
+ from KeyisBClient.gn import GNRequest, GNResponse, CORSObject, FileObject, TemplateObject
34
34
 
35
35
 
36
36
 
@@ -341,7 +341,7 @@ class App:
341
341
  return gn.GNResponse("gn:backend:404", {'error': 'Not Found'})
342
342
 
343
343
 
344
- def fastFile(self, path: str, file_path: str, cors: Optional[gn.CORSObject] = None):
344
+ def fastFile(self, path: str, file_path: str, cors: Optional[gn.CORSObject] = None, template: Optional[gn.TemplateObject] = None, payload: Optional[dict] = None):
345
345
  @self.get(path)
346
346
  async def r_static():
347
347
  nonlocal file_path
@@ -351,13 +351,11 @@ class App:
351
351
  if not os.path.isfile(file_path):
352
352
  return gn.GNResponse('gn:backend:404', cors=cors)
353
353
 
354
- mime_type = guess_type(file_path.split('/')[-1])
355
- async with aiofiles.open(file_path, "rb") as f:
356
- data = await f.read()
354
+ fileObject = gn.FileObject(file_path, template)
355
+ return gn.GNResponse('ok', payload=payload, files=fileObject, cors=cors)
357
356
 
358
- return gn.GNResponse('ok', {'files': [{'mime-type': mime_type, 'data': data}]}, cors=cors)
359
357
 
360
- def static(self, path: str, dir_path: str, cors: Optional[gn.CORSObject] = None):
358
+ def static(self, path: str, dir_path: str, cors: Optional[gn.CORSObject] = None, template: Optional[gn.TemplateObject] = None, payload: Optional[dict] = None):
361
359
  @self.get(f"{path}/{{_path:path}}")
362
360
  async def r_static(_path: str):
363
361
  file_path = os.path.join(dir_path, _path)
@@ -367,12 +365,9 @@ class App:
367
365
 
368
366
  if not os.path.isfile(file_path):
369
367
  return gn.GNResponse('gn:backend:404', cors=cors)
370
-
371
- mime_type = guess_type(file_path.split('/')[-1])
372
- async with aiofiles.open(file_path, "rb") as f:
373
- data = await f.read()
374
-
375
- return gn.GNResponse('ok', {'files': [{'mime-type': mime_type, 'data': data}]}, cors=cors)
368
+
369
+ fileObject = gn.FileObject(file_path, template)
370
+ return gn.GNResponse('ok', payload=payload, files=fileObject, cors=cors)
376
371
 
377
372
 
378
373
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: GNServer
3
- Version: 0.0.0.0.8
3
+ Version: 0.0.0.0.10
4
4
  Summary: GNServer
5
5
  Home-page: https://github.com/KeyisB/libs/tree/main/GNServer
6
6
  Author: KeyisB
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: GNServer
3
- Version: 0.0.0.0.8
3
+ Version: 0.0.0.0.10
4
4
  Summary: GNServer
5
5
  Home-page: https://github.com/KeyisB/libs/tree/main/GNServer
6
6
  Author: KeyisB
@@ -5,7 +5,7 @@ filesName = 'GNServer'
5
5
 
6
6
  setup(
7
7
  name=name,
8
- version='0.0.0.0.8',
8
+ version='0.0.0.0.10',
9
9
  author="KeyisB",
10
10
  author_email="keyisb.pip@gmail.com",
11
11
  description=name,
File without changes
File without changes
File without changes