reyserver 1.1.74__py3-none-any.whl → 1.1.75__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.

Potentially problematic release.


This version of reyserver might be problematic. Click here for more details.

reyserver/__init__.py CHANGED
@@ -14,7 +14,9 @@ rauth : Authentication methods.
14
14
  rbase : Base methods.
15
15
  rclient : Client methods.
16
16
  rfile : File methods.
17
+ rpublic : Public methods.
17
18
  rserver : Server methods.
19
+ rtest : Test methods.
18
20
  """
19
21
 
20
22
 
reyserver/rall.py CHANGED
@@ -13,4 +13,6 @@ from .rauth import *
13
13
  from .rbase import *
14
14
  from .rclient import *
15
15
  from .rfile import *
16
+ from rpublic import *
16
17
  from .rserver import *
18
+ from .rtest import *
reyserver/rbase.py CHANGED
@@ -9,10 +9,9 @@
9
9
  """
10
10
 
11
11
 
12
- from typing import Literal, Type, NoReturn, overload
12
+ from typing import Type, NoReturn, overload
13
13
  from http import HTTPStatus
14
- from fastapi import FastAPI, APIRouter, Request, UploadFile, HTTPException
15
- from fastapi.responses import HTMLResponse, FileResponse
14
+ from fastapi import FastAPI, Request, UploadFile, HTTPException
16
15
  from fastapi.params import (
17
16
  Depends,
18
17
  Path,
@@ -26,7 +25,6 @@ from fastapi.params import (
26
25
  from reydb.rconn import DatabaseConnectionAsync
27
26
  from reydb.rorm import DatabaseORMSessionAsync
28
27
  from reykit.rbase import Base, Exit, StaticMeta, Singleton, throw
29
- from reykit.ros import File, Folder
30
28
 
31
29
  from . import rserver
32
30
 
@@ -376,78 +374,3 @@ class ServerBind(ServerBase, metaclass=StaticMeta):
376
374
 
377
375
 
378
376
  Bind = ServerBind
379
- router_test = APIRouter()
380
- router_public = APIRouter()
381
-
382
-
383
- @router_test.get('/test')
384
- def test() -> Literal['test']:
385
- """
386
- Test.
387
-
388
- Returns
389
- -------
390
- Text `test`.
391
- """
392
-
393
- # Resposne.
394
- response = 'test'
395
-
396
- return response
397
-
398
-
399
- @router_test.post('/test/echo')
400
- def test_echo(data: dict = Bind.i.body) -> dict:
401
- """
402
- Echo test.
403
-
404
- Paremeters
405
- ----------
406
- data : Echo data.
407
-
408
- Returns
409
- -------
410
- Echo data.
411
- """
412
-
413
- # Resposne.
414
-
415
- return data
416
-
417
-
418
- @router_public.get('/')
419
- def home(server: Bind.Server = Bind.server) -> HTMLResponse:
420
- """
421
- Home page.
422
-
423
- Parameters
424
- ----------
425
- Home page HTML content.
426
- """
427
-
428
- # Parameter.
429
- public_dir = server.api_public_dir
430
- file_path = Folder(public_dir) + 'index.html'
431
- file = File(file_path)
432
-
433
- # Response.
434
- response = HTMLResponse(file.str)
435
-
436
- return response
437
-
438
-
439
- @router_public.get('/public/{relpath}')
440
- def get_public_file(relpath: str = Bind.i.path) -> FileResponse:
441
- """
442
- Get public file.
443
-
444
- Parameters
445
- ----------
446
- relpath : Relative path of based on public directory.
447
-
448
- Returns
449
- -------
450
- File.
451
- """
452
-
453
- ...
reyserver/rpublic.py ADDED
@@ -0,0 +1,62 @@
1
+ # !/usr/bin/env python
2
+ # -*- coding: utf-8 -*-
3
+
4
+ """
5
+ @Time : 2025-10-21
6
+ @Author : Rey
7
+ @Contact : reyxbo@163.com
8
+ @Explain : Public methods.
9
+ """
10
+
11
+
12
+ from fastapi import APIRouter
13
+ from fastapi.responses import HTMLResponse, FileResponse
14
+ from reykit.ros import File, Folder
15
+
16
+ from .rbase import Bind
17
+
18
+
19
+ __all__ = (
20
+ 'router_public',
21
+ )
22
+
23
+
24
+ router_public = APIRouter()
25
+
26
+
27
+ @router_public.get('/')
28
+ def home(server: Bind.Server = Bind.server) -> HTMLResponse:
29
+ """
30
+ Home page.
31
+
32
+ Parameters
33
+ ----------
34
+ Home page HTML content.
35
+ """
36
+
37
+ # Parameter.
38
+ public_dir = server.api_public_dir
39
+ file_path = Folder(public_dir) + 'index.html'
40
+ file = File(file_path)
41
+
42
+ # Response.
43
+ response = HTMLResponse(file.str)
44
+
45
+ return response
46
+
47
+
48
+ @router_public.get('/public/{path:path}')
49
+ def get_public_file(path: str = Bind.i.path) -> FileResponse:
50
+ """
51
+ Get public file.
52
+
53
+ Parameters
54
+ ----------
55
+ path : Relative path of based on public directory.
56
+
57
+ Returns
58
+ -------
59
+ File.
60
+ """
61
+
62
+ ...
reyserver/rserver.py CHANGED
@@ -306,28 +306,29 @@ class Server(ServerBase, Singleton):
306
306
  Add test API.
307
307
  """
308
308
 
309
- from .rbase import router_test
309
+ from .rtest import router_test
310
310
 
311
311
  # Add.
312
312
  self.app.include_router(router_test, tags=['test'])
313
313
 
314
314
 
315
- def add_api_public(self, path: str) -> None:
315
+ def add_api_public(self, public_dir: str) -> None:
316
316
  """
317
317
  Add public API,
318
- mapping `{path}/index.html` to 'GET /',
319
- mapping `{path}/{sub_path}` to `GET /public/{sub_path}`.
318
+ mapping `{public_dir}/index.html` to `GET /`,
319
+ mapping `{public_dir}/{path}` to `GET `/public/{path:path}`.
320
320
 
321
321
  Parameters
322
- path : Public directory.
322
+ ----------
323
+ public_dir : Public directory.
323
324
  """
324
325
 
325
- from .rbase import router_public
326
+ from .rpublic import router_public
326
327
 
327
328
  # Add.
328
- self.api_public_dir = path
329
+ self.api_public_dir = public_dir
329
330
  self.app.include_router(router_public, tags=['public'])
330
- subapp = StaticFiles(directory=path)
331
+ subapp = StaticFiles(directory=public_dir)
331
332
  self.app.mount('/public', subapp)
332
333
 
333
334
 
reyserver/rtest.py ADDED
@@ -0,0 +1,58 @@
1
+ # !/usr/bin/env python
2
+ # -*- coding: utf-8 -*-
3
+
4
+ """
5
+ @Time : 2025-10-21
6
+ @Author : Rey
7
+ @Contact : reyxbo@163.com
8
+ @Explain : Test methods.
9
+ """
10
+
11
+
12
+ from typing import Literal
13
+ from fastapi import APIRouter
14
+
15
+ from .rbase import Bind
16
+
17
+
18
+ __all__ = (
19
+ 'router_test',
20
+ )
21
+
22
+
23
+ router_test = APIRouter()
24
+
25
+
26
+ @router_test.get('/test')
27
+ def test() -> Literal['test']:
28
+ """
29
+ Test.
30
+
31
+ Returns
32
+ -------
33
+ Text `test`.
34
+ """
35
+
36
+ # Resposne.
37
+ response = 'test'
38
+
39
+ return response
40
+
41
+
42
+ @router_test.post('/test/echo')
43
+ def test_echo(data: dict = Bind.i.body) -> dict:
44
+ """
45
+ Echo test.
46
+
47
+ Paremeters
48
+ ----------
49
+ data : Echo data.
50
+
51
+ Returns
52
+ -------
53
+ Echo data.
54
+ """
55
+
56
+ # Resposne.
57
+
58
+ return data
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: reyserver
3
- Version: 1.1.74
3
+ Version: 1.1.75
4
4
  Summary: Backend server method set.
5
5
  Project-URL: homepage, https://github.com/reyxbo/reyserver/
6
6
  Author-email: Rey <reyxbo@163.com>
@@ -0,0 +1,13 @@
1
+ reyserver/__init__.py,sha256=umEAldZYjSIpHJQHUOXlgXqMgOiRC-FRGmRZjrji7as,423
2
+ reyserver/rall.py,sha256=SoG4PX2YAz94EuelDNhk1wvwNkrLfzskiWoknEBZitk,315
3
+ reyserver/rauth.py,sha256=SGBtopM4fwn7pFjFPmrh6mD61c0iSJmqYEYUpgoCayA,15217
4
+ reyserver/rbase.py,sha256=hdBRiaGho12D7qoH8P8w7sZK7Jd6xTJSJXIiVoiFNFw,7654
5
+ reyserver/rclient.py,sha256=og5YuWm-PODkFn9njBwYQpGlk0j1BfqFuEarlCFSQYI,6229
6
+ reyserver/rfile.py,sha256=qqJrCwDr27ymXgBs1n6nFwqUrZZs-rxa97isaCOaGNY,8872
7
+ reyserver/rpublic.py,sha256=_JoD3c-jYExarhyvl167zu29j22mUicXeBevjgqSjzk,1085
8
+ reyserver/rserver.py,sha256=5vgYxrZ_s-Njk3zXs4M-Fktx4q6ks0lsHDVgYdMAiE4,10817
9
+ reyserver/rtest.py,sha256=z7i-tKwDzqErebLgF-M2hBg5HUKStK8b9398Yca9s-g,777
10
+ reyserver-1.1.75.dist-info/METADATA,sha256=vJJ2Nb0RV621nqe2VlZut5_jp_do4xXgLwfMw_80wpY,1666
11
+ reyserver-1.1.75.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
12
+ reyserver-1.1.75.dist-info/licenses/LICENSE,sha256=UYLPqp7BvPiH8yEZduJqmmyEl6hlM3lKrFIefiD4rvk,1059
13
+ reyserver-1.1.75.dist-info/RECORD,,
@@ -1,11 +0,0 @@
1
- reyserver/__init__.py,sha256=7GX64p7uI2eetJH9NJ-DTg-8iyQwOsGcviADFJCPxVA,373
2
- reyserver/rall.py,sha256=riyDRTUsigco_Bee1H4aZFb8IgvjnxdX9qcnVb9i9mE,270
3
- reyserver/rauth.py,sha256=SGBtopM4fwn7pFjFPmrh6mD61c0iSJmqYEYUpgoCayA,15217
4
- reyserver/rbase.py,sha256=OKXZ_VOfPEVgO3oVn6j-pqHjnIbDL0UoZtp8GcN9hzw,8990
5
- reyserver/rclient.py,sha256=og5YuWm-PODkFn9njBwYQpGlk0j1BfqFuEarlCFSQYI,6229
6
- reyserver/rfile.py,sha256=qqJrCwDr27ymXgBs1n6nFwqUrZZs-rxa97isaCOaGNY,8872
7
- reyserver/rserver.py,sha256=oel80Z26f0LBJSgBX6hjZbuyGa_N8v_YjEdPzDqrmp4,10761
8
- reyserver-1.1.74.dist-info/METADATA,sha256=YnELfgaINK53X3cIr8RFY-vwexvIHHF6bLWmEzRpSeY,1666
9
- reyserver-1.1.74.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
10
- reyserver-1.1.74.dist-info/licenses/LICENSE,sha256=UYLPqp7BvPiH8yEZduJqmmyEl6hlM3lKrFIefiD4rvk,1059
11
- reyserver-1.1.74.dist-info/RECORD,,