soia-client 1.1.2__py3-none-any.whl → 1.1.3__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.
- soia/_impl/service.py +29 -2
- {soia_client-1.1.2.dist-info → soia_client-1.1.3.dist-info}/METADATA +1 -1
- {soia_client-1.1.2.dist-info → soia_client-1.1.3.dist-info}/RECORD +6 -6
- {soia_client-1.1.2.dist-info → soia_client-1.1.3.dist-info}/WHEEL +0 -0
- {soia_client-1.1.2.dist-info → soia_client-1.1.3.dist-info}/licenses/LICENSE +0 -0
- {soia_client-1.1.2.dist-info → soia_client-1.1.3.dist-info}/top_level.txt +0 -0
soia/_impl/service.py
CHANGED
|
@@ -26,29 +26,50 @@ class _MethodImpl(Generic[Request, Response, RequestHeaders, ResponseHeaders]):
|
|
|
26
26
|
@dataclass(frozen=True)
|
|
27
27
|
class RawServiceResponse:
|
|
28
28
|
data: str
|
|
29
|
-
type: Literal["ok-json", "bad-request", "server-error"]
|
|
29
|
+
type: Literal["ok-json", "ok-html", "bad-request", "server-error"]
|
|
30
30
|
|
|
31
31
|
@property
|
|
32
32
|
def status_code(self):
|
|
33
|
-
if self.type == "ok-json":
|
|
33
|
+
if self.type == "ok-json" or self.type == "ok-html":
|
|
34
34
|
return 200
|
|
35
35
|
elif self.type == "bad-request":
|
|
36
36
|
return 400
|
|
37
37
|
elif self.type == "server-error":
|
|
38
38
|
return 500
|
|
39
39
|
else:
|
|
40
|
+
_: Never = self.type
|
|
40
41
|
raise TypeError(f"Unknown response type: {self.type}")
|
|
41
42
|
|
|
42
43
|
@property
|
|
43
44
|
def content_type(self):
|
|
44
45
|
if self.type == "ok-json":
|
|
45
46
|
return "application/json"
|
|
47
|
+
if self.type == "ok-html":
|
|
48
|
+
return "text/html; charset=utf-8"
|
|
46
49
|
elif self.type == "bad-request" or self.type == "server-error":
|
|
47
50
|
return "text/plain; charset=utf-8"
|
|
48
51
|
else:
|
|
52
|
+
_: Never = self.type
|
|
49
53
|
raise TypeError(f"Unknown response type: {self.type}")
|
|
50
54
|
|
|
51
55
|
|
|
56
|
+
# Copied from
|
|
57
|
+
# https://github.com/gepheum/restudio/blob/main/index.jsdeliver.html
|
|
58
|
+
_RESTUDIO_HTML = """<!DOCTYPE html>
|
|
59
|
+
|
|
60
|
+
<html>
|
|
61
|
+
<head>
|
|
62
|
+
<meta charset="utf-8" />
|
|
63
|
+
<title>RESTudio</title>
|
|
64
|
+
<script src="dist/restudio-standalone.js"></script>
|
|
65
|
+
</head>
|
|
66
|
+
<body style="margin: 0; padding: 0;">
|
|
67
|
+
<restudio-app></restudio-app>
|
|
68
|
+
</body>
|
|
69
|
+
</html>
|
|
70
|
+
"""
|
|
71
|
+
|
|
72
|
+
|
|
52
73
|
@dataclass()
|
|
53
74
|
class _HandleRequestFlow(Generic[Request, Response, RequestHeaders, ResponseHeaders]):
|
|
54
75
|
req_body: str
|
|
@@ -94,6 +115,9 @@ class _HandleRequestFlow(Generic[Request, Response, RequestHeaders, ResponseHead
|
|
|
94
115
|
if self.req_body in ["", "list"]:
|
|
95
116
|
return self._handle_list()
|
|
96
117
|
|
|
118
|
+
if self.req_body == "restudio":
|
|
119
|
+
return self._handle_restudio()
|
|
120
|
+
|
|
97
121
|
# Method invokation
|
|
98
122
|
method_name: str
|
|
99
123
|
method_number: int | None
|
|
@@ -211,6 +235,9 @@ class _HandleRequestFlow(Generic[Request, Response, RequestHeaders, ResponseHead
|
|
|
211
235
|
)
|
|
212
236
|
return RawServiceResponse(json_code, "ok-json")
|
|
213
237
|
|
|
238
|
+
def _handle_restudio(self) -> RawServiceResponse:
|
|
239
|
+
return RawServiceResponse(_RESTUDIO_HTML, "ok-html")
|
|
240
|
+
|
|
214
241
|
def _response_to_json(
|
|
215
242
|
self,
|
|
216
243
|
res: Response,
|
|
@@ -15,13 +15,13 @@ soia/_impl/primitives.py,sha256=r-55rO12TwwWCQJgzEEgVpXMVGg0dRhGvFWX_rGeqsQ,9025
|
|
|
15
15
|
soia/_impl/repr.py,sha256=7WX0bEAVENTjlyZIcbT8TcJylS7IRIyafGCmqaIMxFM,1413
|
|
16
16
|
soia/_impl/serializer.py,sha256=28IwkjtUnLpbnPQfVNfJXkApCK4JhXHwLkC5MVhF8xo,3529
|
|
17
17
|
soia/_impl/serializers.py,sha256=IL9jHHMo11pgrL1-crarOEElvTyV5YM6FTcgumjW6IU,2564
|
|
18
|
-
soia/_impl/service.py,sha256=
|
|
18
|
+
soia/_impl/service.py,sha256=zwxbFojyyrFm8_xc8PN8xMmMKPqC92BarUjhxYza5Hc,15535
|
|
19
19
|
soia/_impl/service_client.py,sha256=0WgiN6Stg548FAdZQMuezZoooe4MYw2frEQ5KUE7xag,5311
|
|
20
20
|
soia/_impl/structs.py,sha256=1XhjZmqtD7IMURdSVR0DwMdrIhWPZft1eCfwVW84c0E,28230
|
|
21
21
|
soia/_impl/timestamp.py,sha256=upnEkvW-7AaMJ9_nNqntvhJ4pFWWCAXNjEOPtszdwgE,5645
|
|
22
22
|
soia/_impl/type_adapter.py,sha256=RyIyh4Fnt9rMy0HRzC-a2v2JAdZsV9FBzoGEUVygVRE,2101
|
|
23
|
-
soia_client-1.1.
|
|
24
|
-
soia_client-1.1.
|
|
25
|
-
soia_client-1.1.
|
|
26
|
-
soia_client-1.1.
|
|
27
|
-
soia_client-1.1.
|
|
23
|
+
soia_client-1.1.3.dist-info/licenses/LICENSE,sha256=SaAftKkX6hfSOiPdENQPS70tifH3PDHgazq8eK2Pwfw,1064
|
|
24
|
+
soia_client-1.1.3.dist-info/METADATA,sha256=kDuwtQ-gADi4JKDkYk_ZtRJPRJR4qiHb9fylrWoeAzA,2121
|
|
25
|
+
soia_client-1.1.3.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
|
26
|
+
soia_client-1.1.3.dist-info/top_level.txt,sha256=lsYG9JrvauFe1oIV5zvnwsS9hsx3ztwfK_937op9mxc,5
|
|
27
|
+
soia_client-1.1.3.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|