robyn 0.73.0__cp311-cp311-macosx_10_12_x86_64.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 robyn might be problematic. Click here for more details.

Files changed (57) hide show
  1. robyn/__init__.py +757 -0
  2. robyn/__main__.py +4 -0
  3. robyn/ai.py +308 -0
  4. robyn/argument_parser.py +129 -0
  5. robyn/authentication.py +96 -0
  6. robyn/cli.py +136 -0
  7. robyn/dependency_injection.py +71 -0
  8. robyn/env_populator.py +35 -0
  9. robyn/events.py +6 -0
  10. robyn/exceptions.py +32 -0
  11. robyn/jsonify.py +13 -0
  12. robyn/logger.py +80 -0
  13. robyn/mcp.py +461 -0
  14. robyn/openapi.py +448 -0
  15. robyn/processpool.py +226 -0
  16. robyn/py.typed +0 -0
  17. robyn/reloader.py +164 -0
  18. robyn/responses.py +208 -0
  19. robyn/robyn.cpython-311-darwin.so +0 -0
  20. robyn/robyn.pyi +421 -0
  21. robyn/router.py +410 -0
  22. robyn/scaffold/mongo/Dockerfile +12 -0
  23. robyn/scaffold/mongo/app.py +43 -0
  24. robyn/scaffold/mongo/requirements.txt +2 -0
  25. robyn/scaffold/no-db/Dockerfile +12 -0
  26. robyn/scaffold/no-db/app.py +12 -0
  27. robyn/scaffold/no-db/requirements.txt +1 -0
  28. robyn/scaffold/postgres/Dockerfile +32 -0
  29. robyn/scaffold/postgres/app.py +31 -0
  30. robyn/scaffold/postgres/requirements.txt +3 -0
  31. robyn/scaffold/postgres/supervisord.conf +14 -0
  32. robyn/scaffold/prisma/Dockerfile +15 -0
  33. robyn/scaffold/prisma/app.py +32 -0
  34. robyn/scaffold/prisma/requirements.txt +2 -0
  35. robyn/scaffold/prisma/schema.prisma +13 -0
  36. robyn/scaffold/sqlalchemy/Dockerfile +12 -0
  37. robyn/scaffold/sqlalchemy/__init__.py +0 -0
  38. robyn/scaffold/sqlalchemy/app.py +13 -0
  39. robyn/scaffold/sqlalchemy/models.py +21 -0
  40. robyn/scaffold/sqlalchemy/requirements.txt +2 -0
  41. robyn/scaffold/sqlite/Dockerfile +12 -0
  42. robyn/scaffold/sqlite/app.py +22 -0
  43. robyn/scaffold/sqlite/requirements.txt +1 -0
  44. robyn/scaffold/sqlmodel/Dockerfile +11 -0
  45. robyn/scaffold/sqlmodel/app.py +46 -0
  46. robyn/scaffold/sqlmodel/models.py +10 -0
  47. robyn/scaffold/sqlmodel/requirements.txt +2 -0
  48. robyn/status_codes.py +137 -0
  49. robyn/swagger.html +32 -0
  50. robyn/templating.py +30 -0
  51. robyn/types.py +44 -0
  52. robyn/ws.py +67 -0
  53. robyn-0.73.0.dist-info/METADATA +32 -0
  54. robyn-0.73.0.dist-info/RECORD +57 -0
  55. robyn-0.73.0.dist-info/WHEEL +4 -0
  56. robyn-0.73.0.dist-info/entry_points.txt +3 -0
  57. robyn-0.73.0.dist-info/licenses/LICENSE +25 -0
robyn/robyn.pyi ADDED
@@ -0,0 +1,421 @@
1
+ from __future__ import annotations
2
+
3
+ from dataclasses import dataclass
4
+ from enum import Enum
5
+ from typing import Callable, Optional, Union
6
+
7
+ def get_version() -> str:
8
+ pass
9
+
10
+ class SocketHeld:
11
+ def __init__(self, url: str, port: int):
12
+ pass
13
+ def try_clone(self) -> SocketHeld:
14
+ pass
15
+
16
+ class MiddlewareType(Enum):
17
+ """
18
+ The middleware types supported by Robyn.
19
+
20
+ Attributes:
21
+ BEFORE_REQUEST: str
22
+ AFTER_REQUEST: str
23
+ """
24
+
25
+ BEFORE_REQUEST: str
26
+ AFTER_REQUEST: str
27
+
28
+ class HttpMethod(Enum):
29
+ """
30
+ The HTTP methods supported by Robyn.
31
+
32
+ Attributes:
33
+ GET: str
34
+ POST: str
35
+ PUT: str
36
+ DELETE: str
37
+ PATCH: str
38
+ OPTIONS: str
39
+ HEAD: str
40
+ TRACE: str
41
+ CONNECT: str
42
+ """
43
+
44
+ GET: str
45
+ POST: str
46
+ PUT: str
47
+ DELETE: str
48
+ PATCH: str
49
+ OPTIONS: str
50
+ HEAD: str
51
+ TRACE: str
52
+ CONNECT: str
53
+
54
+ @dataclass
55
+ class FunctionInfo:
56
+ """
57
+ The function info object passed to the route handler.
58
+
59
+ Attributes:
60
+ handler (Callable): The function to be called
61
+ is_async (bool): Whether the function is async or not
62
+ number_of_params (int): The number of parameters the function has
63
+ args (dict): The arguments of the function
64
+ kwargs (dict): The keyword arguments of the function
65
+ """
66
+
67
+ handler: Callable
68
+ is_async: bool
69
+ number_of_params: int
70
+ args: dict
71
+ kwargs: dict
72
+
73
+ @dataclass
74
+ class Url:
75
+ """
76
+ The url object passed to the route handler.
77
+
78
+ Attributes:
79
+ scheme (str): The scheme of the url. e.g. http, https
80
+ host (str): The host of the url. e.g. localhost,
81
+ path (str): The path of the url. e.g. /user
82
+ """
83
+
84
+ scheme: str
85
+ host: str
86
+ path: str
87
+
88
+ @dataclass
89
+ class Identity:
90
+ claims: dict[str, str]
91
+
92
+ class QueryParams:
93
+ """
94
+ The query params object passed to the route handler.
95
+
96
+ Attributes:
97
+ queries (dict[str, list[str]]): The query parameters of the request. e.g. /user?id=123 -> {"id": "123"}
98
+ """
99
+
100
+ def set(self, key: str, value: str) -> None:
101
+ """
102
+ Sets the value of the query parameter with the given key.
103
+ If the key already exists, the value will be appended to the list of values.
104
+
105
+ Args:
106
+ key (str): The key of the query parameter
107
+ value (str): The value of the query parameter
108
+ """
109
+ pass
110
+
111
+ def get(self, key: str, default: Optional[str] = None) -> Optional[str]:
112
+ """
113
+ Gets the last value of the query parameter with the given key.
114
+
115
+ Args:
116
+ key (str): The key of the query parameter
117
+ default (Optional[str]): The default value if the key does not exist
118
+ """
119
+ pass
120
+
121
+ def empty(self) -> bool:
122
+ """
123
+ Returns:
124
+ True if the query params are empty, False otherwise
125
+ """
126
+ pass
127
+
128
+ def contains(self, key: str) -> bool:
129
+ """
130
+ Returns:
131
+ True if the query params contain the key, False otherwise
132
+
133
+ Args:
134
+ key (str): The key of the query parameter
135
+ """
136
+ pass
137
+
138
+ def get_first(self, key: str) -> Optional[str]:
139
+ """
140
+ Gets the first value of the query parameter with the given key.
141
+
142
+ Args:
143
+ key (str): The key of the query parameter
144
+
145
+ """
146
+ pass
147
+
148
+ def get_all(self, key: str) -> Optional[list[str]]:
149
+ """
150
+ Gets all the values of the query parameter with the given key.
151
+
152
+ Args:
153
+ key (str): The key of the query parameter
154
+ """
155
+ pass
156
+
157
+ def extend(self, other: QueryParams) -> None:
158
+ """
159
+ Extends the query params with the other query params.
160
+
161
+ Args:
162
+ other (QueryParams): The other QueryParams object
163
+ """
164
+ pass
165
+
166
+ def to_dict(self) -> dict[str, list[str]]:
167
+ """
168
+ Returns:
169
+ The query params as a dictionary
170
+ """
171
+ pass
172
+
173
+ def __contains__(self, key: str) -> bool:
174
+ pass
175
+
176
+ def __repr__(self) -> str:
177
+ pass
178
+
179
+ class Headers:
180
+ def __init__(self, default_headers: Optional[dict]) -> None:
181
+ pass
182
+
183
+ def __getitem__(self, key: str) -> Optional[str]:
184
+ pass
185
+
186
+ def __setitem__(self, key: str, value: str) -> None:
187
+ pass
188
+
189
+ def set(self, key: str, value: str) -> None:
190
+ """
191
+ Sets the value of the header with the given key.
192
+ If the key already exists, the value will be appended to the list of values.
193
+
194
+ Args:
195
+ key (str): The key of the header
196
+ value (str): The value of the header
197
+ """
198
+ pass
199
+
200
+ def get(self, key: str) -> Optional[str]:
201
+ """
202
+ Gets the last value of the header with the given key.
203
+
204
+ Args:
205
+ key (str): The key of the header
206
+ """
207
+ pass
208
+
209
+ def populate_from_dict(self, headers: dict[str, str]) -> None:
210
+ """
211
+ Populates the headers from a dictionary.
212
+
213
+ Args:
214
+ headers (dict[str, str]): The dictionary of headers
215
+ """
216
+ pass
217
+
218
+ def contains(self, key: str) -> bool:
219
+ """
220
+ Returns:
221
+ True if the headers contain the key, False otherwise
222
+
223
+ Args:
224
+ key (str): The key of the header
225
+ """
226
+ pass
227
+
228
+ def append(self, key: str, value: str) -> None:
229
+ """
230
+ Appends the value to the header with the given key.
231
+
232
+ Args:
233
+ key (str): The key of the header
234
+ value (str): The value of the header
235
+ """
236
+ pass
237
+
238
+ def is_empty(self) -> bool:
239
+ """
240
+ Returns:
241
+ True if the headers are empty, False otherwise
242
+ """
243
+ pass
244
+
245
+ @dataclass
246
+ class Request:
247
+ """
248
+ The request object passed to the route handler.
249
+
250
+ Attributes:
251
+ query_params (QueryParams): The query parameters of the request. e.g. /user?id=123 -> {"id": "123"}
252
+ headers Headers: The headers of the request. e.g. Headers({"Content-Type": "application/json"})
253
+ path_params (dict[str, str]): The parameters of the request. e.g. /user/:id -> {"id": "123"}
254
+ body (Union[str, bytes]): The body of the request. If the request is a JSON, it will be a dict.
255
+ method (str): The method of the request. e.g. GET, POST, PUT etc.
256
+ url (Url): The url of the request. e.g. https://localhost/user
257
+ form_data (dict[str, str]): The form data of the request. e.g. {"name": "John"}
258
+ files (dict[str, bytes]): The files of the request. e.g. {"file": b"file"}
259
+ ip_addr (Optional[str]): The IP Address of the client
260
+ identity (Optional[Identity]): The identity of the client
261
+ """
262
+
263
+ query_params: QueryParams
264
+ headers: Headers
265
+ path_params: dict[str, str]
266
+ body: Union[str, bytes]
267
+ method: str
268
+ url: Url
269
+ form_data: dict[str, str]
270
+ files: dict[str, bytes]
271
+ ip_addr: Optional[str]
272
+ identity: Optional[Identity]
273
+
274
+ def json(self) -> dict:
275
+ """
276
+ If the body is a valid JSON this will return the parsed JSON data.
277
+ Otherwise, this will throw a ValueError.
278
+ """
279
+ pass
280
+
281
+ @dataclass
282
+ class Response:
283
+ """
284
+ The response object passed to the route handler.
285
+
286
+ Attributes:
287
+ status_code (int): The status code of the response. e.g. 200, 404, 500 etc.
288
+ response_type (Optional[str]): The response type of the response. e.g. text, json, html, file etc.
289
+ headers (Union[Headers, dict]): The headers of the response or Headers directly. e.g. {"Content-Type": "application/json"}
290
+ description (Union[str, bytes]): The body of the response. If the response is a JSON, it will be a dict.
291
+ file_path (Optional[str]): The file path of the response. e.g. /home/user/file.txt
292
+ """
293
+
294
+ status_code: int
295
+ headers: Union[Headers, dict]
296
+ description: Union[str, bytes]
297
+ response_type: Optional[str] = None
298
+ file_path: Optional[str] = None
299
+
300
+ def set_cookie(self, key: str, value: str) -> None:
301
+ """
302
+ Sets the cookie in the response.
303
+
304
+ Args:
305
+ key (str): The key of the cookie
306
+ value (str): The value of the cookie
307
+ """
308
+ pass
309
+
310
+ class Server:
311
+ """
312
+ The Server object used to create a Robyn server.
313
+
314
+ This object is used to create a Robyn server and add routes, middlewares, etc.
315
+ """
316
+ def __init__(self) -> None:
317
+ pass
318
+ def add_directory(
319
+ self,
320
+ route: str,
321
+ directory_path: str,
322
+ show_files_listing: bool,
323
+ index_file: Optional[str],
324
+ ) -> None:
325
+ pass
326
+ def apply_request_headers(self, headers: Headers) -> None:
327
+ pass
328
+ def apply_response_headers(self, headers: Headers) -> None:
329
+ pass
330
+ def set_response_headers_exclude_paths(self, excluded_response_headers_paths: Optional[list[str]] = None):
331
+ pass
332
+
333
+ def add_route(
334
+ self,
335
+ route_type: HttpMethod,
336
+ route: str,
337
+ function: FunctionInfo,
338
+ is_const: bool,
339
+ ) -> None:
340
+ pass
341
+ def add_global_middleware(self, middleware_type: MiddlewareType, function: FunctionInfo) -> None:
342
+ pass
343
+ def add_middleware_route(
344
+ self,
345
+ middleware_type: MiddlewareType,
346
+ route: str,
347
+ function: FunctionInfo,
348
+ route_type: HttpMethod,
349
+ ) -> None:
350
+ pass
351
+ def add_startup_handler(self, function: FunctionInfo) -> None:
352
+ pass
353
+ def add_shutdown_handler(self, function: FunctionInfo) -> None:
354
+ pass
355
+ def add_web_socket_route(
356
+ self,
357
+ route: str,
358
+ connect_route: FunctionInfo,
359
+ close_route: FunctionInfo,
360
+ message_route: FunctionInfo,
361
+ ) -> None:
362
+ pass
363
+ def start(self, socket: SocketHeld, workers: int, client_timeout: int, keep_alive_timeout: int) -> None:
364
+ pass
365
+
366
+ class WebSocketConnector:
367
+ """
368
+ The WebSocketConnector object passed to the route handler.
369
+
370
+ Attributes:
371
+ id (str): The id of the client
372
+ query_params (QueryParams): The query parameters object
373
+
374
+ async_broadcast (Callable): The function to broadcast a message to all clients
375
+ async_send_to (Callable): The function to send a message to the client
376
+ sync_broadcast (Callable): The function to broadcast a message to all clients
377
+ sync_send_to (Callable): The function to send a message to the client
378
+ """
379
+
380
+ id: str
381
+ query_params: QueryParams
382
+
383
+ async def async_broadcast(self, message: str) -> None:
384
+ """
385
+ Broadcasts a message to all clients.
386
+
387
+ Args:
388
+ message (str): The message to broadcast
389
+ """
390
+ pass
391
+ async def async_send_to(self, sender_id: str, message: str) -> None:
392
+ """
393
+ Sends a message to a specific client.
394
+
395
+ Args:
396
+ sender_id (str): The id of the sender
397
+ message (str): The message to send
398
+ """
399
+ pass
400
+ def sync_broadcast(self, message: str) -> None:
401
+ """
402
+ Broadcasts a message to all clients.
403
+
404
+ Args:
405
+ message (str): The message to broadcast
406
+ """
407
+ pass
408
+ def sync_send_to(self, sender_id: str, message: str) -> None:
409
+ """
410
+ Sends a message to a specific client.
411
+
412
+ Args:
413
+ sender_id (str): The id of the sender
414
+ message (str): The message to send
415
+ """
416
+ pass
417
+ def close(self) -> None:
418
+ """
419
+ Closes the connection.
420
+ """
421
+ pass