reyserver 1.1.36__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.
reyserver/__init__.py ADDED
@@ -0,0 +1,15 @@
1
+ # !/usr/bin/env python
2
+ # -*- coding: utf-8 -*-
3
+
4
+ """
5
+ @Time : 2023-02-19 18:59:26
6
+ @Author : Rey
7
+ @Contact : reyxbo@163.com
8
+ @Explain : Backend server method set.
9
+
10
+ Modules
11
+ -------
12
+ rall : All methods.
13
+ rbase : Base methods.
14
+ rserver : Server methods.
15
+ """
reyserver/rall.py ADDED
@@ -0,0 +1,13 @@
1
+ # !/usr/bin/env python
2
+ # -*- coding: utf-8 -*-
3
+
4
+ """
5
+ @Time : 2024-01-11 22:47:52
6
+ @Author : Rey
7
+ @Contact : reyxbo@163.com
8
+ @Explain : All methods.
9
+ """
10
+
11
+
12
+ from .rbase import *
13
+ from .rserver import *
reyserver/rbase.py ADDED
@@ -0,0 +1,23 @@
1
+ # !/usr/bin/env python
2
+ # -*- coding: utf-8 -*-
3
+
4
+ """
5
+ @Time : 2025-07-17 22:32:37
6
+ @Author : Rey
7
+ @Contact : reyxbo@163.com
8
+ @Explain : Base methods.
9
+ """
10
+
11
+
12
+ from reykit.rbase import Base
13
+
14
+
15
+ __all__ = (
16
+ 'ServerBase',
17
+ )
18
+
19
+
20
+ class ServerBase(Base):
21
+ """
22
+ Server base type.
23
+ """
reyserver/rserver.py ADDED
@@ -0,0 +1,118 @@
1
+ # !/usr/bin/env python
2
+ # -*- coding: utf-8 -*-
3
+
4
+ """
5
+ @Time : 2025-10-05 00:55:28
6
+ @Author : Rey
7
+ @Contact : reyxbo@163.com
8
+ @Explain : Server methods.
9
+ """
10
+
11
+
12
+ from typing import Literal
13
+ from collections.abc import Sequence, Callable, Coroutine
14
+ from types import CoroutineType
15
+ from inspect import iscoroutinefunction, iscoroutine
16
+ from fastapi import FastAPI, Depends as get_depends
17
+ from fastapi.params import Depends
18
+ # from fastapi.middleware.cors import CORSMiddleware
19
+ from fastapi.middleware.gzip import GZipMiddleware
20
+ from fastapi.middleware.trustedhost import TrustedHostMiddleware
21
+ from fastapi.middleware.httpsredirect import HTTPSRedirectMiddleware
22
+ from fastapi.staticfiles import StaticFiles
23
+ from uvicorn import run as uvicorn_run
24
+ from fastapi.responses import HTMLResponse
25
+ from reykit.ros import File, Folder
26
+ from reykit.rbase import CoroutineFunction
27
+
28
+ from .rbase import ServerBase
29
+
30
+
31
+ __all__ = (
32
+ 'Server',
33
+ )
34
+
35
+
36
+ type CoroutineFunction = Callable[[], Coroutine]
37
+
38
+
39
+ class Server(ServerBase):
40
+ """
41
+ Server type.
42
+ Based on `fastapi` and `uvicorn` package.
43
+ """
44
+
45
+
46
+ def __init__(
47
+ self,
48
+ public: str | None = None,
49
+ depend: CoroutineFunction | Sequence[CoroutineFunction] | None = None,
50
+ before: CoroutineFunction | Sequence[CoroutineFunction] | None = None,
51
+ after: CoroutineFunction | Sequence[CoroutineFunction] | None = None,
52
+ ssl_cert: str | None = None,
53
+ ssl_key: str | None = None,
54
+ ) -> None:
55
+ """
56
+ Build instance attributes.
57
+
58
+ Parameters
59
+ ----------
60
+ public : Public directory.
61
+ depend : Global api dependencies.
62
+ before : Before
63
+ """
64
+
65
+ # Parameter.
66
+ if type(ssl_cert) != type(ssl_key):
67
+ raise
68
+
69
+ # Build.
70
+ self.app = FastAPI()
71
+ # self.index = Folder(public) + 'index.html'
72
+ self.ssl_cert = ssl_cert
73
+ self.ssl_key = ssl_key
74
+
75
+ ## Middleware.
76
+ self.app.add_middleware(GZipMiddleware)
77
+ # self.app.add_middleware(TrustedHostMiddleware)
78
+ # self.app.add_middleware(HTTPSRedirectMiddleware)
79
+
80
+ ## Static.
81
+ if public is not None:
82
+ subapp = StaticFiles(directory=public, html=True)
83
+ self.app.mount('/', subapp)
84
+
85
+
86
+ def run(self):
87
+ """
88
+ Run.
89
+ """
90
+
91
+ # Run.
92
+ uvicorn_run(
93
+ self.app,
94
+ ssl_certfile=self.ssl_cert,
95
+ ssl_keyfile=self.ssl_key
96
+ )
97
+
98
+
99
+ def add_api_all(self):
100
+
101
+ self.add_api_all()
102
+
103
+
104
+ def add_api_base(self):
105
+
106
+ # @self.app.get('/')
107
+ # def index():
108
+ # file_bytes = File(self.index).bytes
109
+ # response = HTMLResponse(file_bytes)
110
+ # return response
111
+
112
+
113
+ @self.app.get('/test')
114
+ def test():
115
+ return {'message': 'test'}
116
+
117
+
118
+ def add_api_file(self): ...
@@ -0,0 +1,28 @@
1
+ Metadata-Version: 2.4
2
+ Name: reyserver
3
+ Version: 1.1.36
4
+ Summary: Backend server method set.
5
+ Project-URL: homepage, https://github.com/reyxbo/reyserver/
6
+ Author-email: Rey <reyxbo@163.com>
7
+ License: Copyright 2025 ReyXBo
8
+
9
+ Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
12
+
13
+ THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
14
+ License-File: LICENSE
15
+ Keywords: API,async,asynchronous,backend,rey,reyxbo,server
16
+ Requires-Python: >=3.12
17
+ Requires-Dist: reykit
18
+ Description-Content-Type: text/markdown
19
+
20
+ # reyserver
21
+
22
+ > Backend server method set.
23
+
24
+ ## Install
25
+
26
+ ```
27
+ pip install reyserver
28
+ ```
@@ -0,0 +1,8 @@
1
+ reyserver/__init__.py,sha256=xNiwJwOqcsCbTODxZict7-MsU0cWlzYuIEE770o9-VI,266
2
+ reyserver/rall.py,sha256=4z6iHnQ43Y1UYOLoNdPN117h5LKNUWm6fhOZ5-QJK8w,211
3
+ reyserver/rbase.py,sha256=TANYMgAdpgCZoMv3WK72rARo0zNQeCFcraWYXZu96WI,306
4
+ reyserver/rserver.py,sha256=AYAB5wXObhuFrC3prz_MYyXOKadCX2hMR-llxHSF6mI,2976
5
+ reyserver-1.1.36.dist-info/METADATA,sha256=4AvsxMuZ11NmQuM4C3DH69sqyhvhSsp4ApIzr-GXS0Y,1549
6
+ reyserver-1.1.36.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
7
+ reyserver-1.1.36.dist-info/licenses/LICENSE,sha256=UYLPqp7BvPiH8yEZduJqmmyEl6hlM3lKrFIefiD4rvk,1059
8
+ reyserver-1.1.36.dist-info/RECORD,,
@@ -0,0 +1,4 @@
1
+ Wheel-Version: 1.0
2
+ Generator: hatchling 1.27.0
3
+ Root-Is-Purelib: true
4
+ Tag: py3-none-any
@@ -0,0 +1,7 @@
1
+ Copyright 2025 ReyXBo
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
4
+
5
+ The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
6
+
7
+ THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.