GNServer 0.0.0.0.6__py3-none-any.whl → 0.0.0.0.7__py3-none-any.whl
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.
- GNServer/__init__.py +1 -1
- GNServer/_app.py +22 -5
- {gnserver-0.0.0.0.6.dist-info → gnserver-0.0.0.0.7.dist-info}/METADATA +1 -1
- gnserver-0.0.0.0.7.dist-info/RECORD +8 -0
- gnserver-0.0.0.0.6.dist-info/RECORD +0 -8
- {gnserver-0.0.0.0.6.dist-info → gnserver-0.0.0.0.7.dist-info}/WHEEL +0 -0
- {gnserver-0.0.0.0.6.dist-info → gnserver-0.0.0.0.7.dist-info}/licenses/LICENSE +0 -0
- {gnserver-0.0.0.0.6.dist-info → gnserver-0.0.0.0.7.dist-info}/top_level.txt +0 -0
GNServer/__init__.py
CHANGED
GNServer/_app.py
CHANGED
@@ -230,6 +230,7 @@ class App:
|
|
230
230
|
|
231
231
|
def delete(self, path: str, *, cors: Optional[gn.CORSObject] = None):
|
232
232
|
return self.route("DELETE", path, cors)
|
233
|
+
|
233
234
|
|
234
235
|
def setRouteCors(self, cors: Optional[gn.CORSObject] = None):
|
235
236
|
self._cors = cors
|
@@ -287,7 +288,23 @@ class App:
|
|
287
288
|
return gn.GNResponse("gn:backend:404", {'error': 'Not Found'})
|
288
289
|
|
289
290
|
|
290
|
-
def
|
291
|
+
def fastFile(self, path: str, file_path: str, cors: Optional[gn.CORSObject] = None):
|
292
|
+
@self.get(path)
|
293
|
+
async def r_static(path: str):
|
294
|
+
nonlocal file_path
|
295
|
+
if file_path.endswith('/'):
|
296
|
+
file_path = file_path[:-1]
|
297
|
+
|
298
|
+
if not os.path.isfile(file_path):
|
299
|
+
return gn.GNResponse('gn:backend:404', cors=cors)
|
300
|
+
|
301
|
+
mime_type = guess_type(file_path.split('/')[-1])
|
302
|
+
async with aiofiles.open(file_path, "rb") as f:
|
303
|
+
data = await f.read()
|
304
|
+
|
305
|
+
return gn.GNResponse('ok', {'files': [{'mime-type': mime_type, 'data': data}]}, cors=cors)
|
306
|
+
|
307
|
+
def static(self, path: str, dir_path: str, cors: Optional[gn.CORSObject] = None):
|
291
308
|
@self.get(f"{path}/{{_path:path}}")
|
292
309
|
async def r_static(_path: str):
|
293
310
|
file_path = os.path.join(dir_path, _path)
|
@@ -296,13 +313,13 @@ class App:
|
|
296
313
|
file_path = file_path[:-1]
|
297
314
|
|
298
315
|
if not os.path.isfile(file_path):
|
299
|
-
return gn.GNResponse('gn:backend:404')
|
316
|
+
return gn.GNResponse('gn:backend:404', cors=cors)
|
300
317
|
|
301
318
|
mime_type = guess_type(file_path.split('/')[-1])
|
302
319
|
async with aiofiles.open(file_path, "rb") as f:
|
303
320
|
data = await f.read()
|
304
321
|
|
305
|
-
return gn.GNResponse('ok', {'files': [{'mime-type': mime_type, 'data': data}]})
|
322
|
+
return gn.GNResponse('ok', {'files': [{'mime-type': mime_type, 'data': data}]}, cors=cors)
|
306
323
|
|
307
324
|
|
308
325
|
|
@@ -419,7 +436,7 @@ class App:
|
|
419
436
|
if inspect.isasyncgen(response):
|
420
437
|
async for chunk in response: # type: ignore[misc]
|
421
438
|
chunk._stream = True
|
422
|
-
chunk = self.resolve_response(chunk)
|
439
|
+
chunk = await self.resolve_response(chunk)
|
423
440
|
self._quic.send_stream_data(request.stream_id, chunk.serialize(3), end_stream=False)
|
424
441
|
self.transmit()
|
425
442
|
|
@@ -431,7 +448,7 @@ class App:
|
|
431
448
|
return
|
432
449
|
|
433
450
|
|
434
|
-
response = self.resolve_response(response)
|
451
|
+
response = await self.resolve_response(response)
|
435
452
|
self._quic.send_stream_data(request.stream_id, response.serialize(3), end_stream=True)
|
436
453
|
logger.debug(f'Отправлен на сервер ответ -> {response.command} {response.payload if response.payload and len((response.payload)) < 200 else ''}')
|
437
454
|
self.transmit()
|
@@ -0,0 +1,8 @@
|
|
1
|
+
GNServer/__init__.py,sha256=l9B6gZZ2gTkWvNdla--J15_Bj0BtP8RyPsrMI6amgDo,1376
|
2
|
+
GNServer/_app.py,sha256=w2rK4nrDWVZ_f0c3tC2cVckvkb8gY4Xudajiajw6yqQ,18534
|
3
|
+
GNServer/models.py,sha256=3HTbPgXMcltK3hh3RWii0z6X2qYitXmPWzud8pOc4Rk,50
|
4
|
+
gnserver-0.0.0.0.7.dist-info/licenses/LICENSE,sha256=WH_t7dKZyWJ5Ld07eYIkUG4Tv6zZWXtAdsUqYAUesn0,1084
|
5
|
+
gnserver-0.0.0.0.7.dist-info/METADATA,sha256=bqObiR6rIxTCq4Lg_GU9oRyYbw6B1wg2NggJV2qrg5c,804
|
6
|
+
gnserver-0.0.0.0.7.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
7
|
+
gnserver-0.0.0.0.7.dist-info/top_level.txt,sha256=-UOUBuD4u7Qkb1o5PdcwyA3kx8xCH2lwy0tJHi26Wb4,9
|
8
|
+
gnserver-0.0.0.0.7.dist-info/RECORD,,
|
@@ -1,8 +0,0 @@
|
|
1
|
-
GNServer/__init__.py,sha256=T6kT6WoJpmIXashMSHfuafb9DSePUIzw192h27j9a4M,1364
|
2
|
-
GNServer/_app.py,sha256=8JcVzozjtdLtQjPThi-wR2OaAYNvYfaIqDReCmmFmrg,17801
|
3
|
-
GNServer/models.py,sha256=3HTbPgXMcltK3hh3RWii0z6X2qYitXmPWzud8pOc4Rk,50
|
4
|
-
gnserver-0.0.0.0.6.dist-info/licenses/LICENSE,sha256=WH_t7dKZyWJ5Ld07eYIkUG4Tv6zZWXtAdsUqYAUesn0,1084
|
5
|
-
gnserver-0.0.0.0.6.dist-info/METADATA,sha256=S5wZWPijiIAS9Kd8BkMeKs7PJtY0CMeMVvp149dQyhI,804
|
6
|
-
gnserver-0.0.0.0.6.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
7
|
-
gnserver-0.0.0.0.6.dist-info/top_level.txt,sha256=-UOUBuD4u7Qkb1o5PdcwyA3kx8xCH2lwy0tJHi26Wb4,9
|
8
|
-
gnserver-0.0.0.0.6.dist-info/RECORD,,
|
File without changes
|
File without changes
|
File without changes
|