muscles-wsgi 1.0.0__tar.gz
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.
- muscles_wsgi-1.0.0/PKG-INFO +139 -0
- muscles_wsgi-1.0.0/README.md +110 -0
- muscles_wsgi-1.0.0/pyproject.toml +35 -0
- muscles_wsgi-1.0.0/src/muscles/wsgi/Makefile +26 -0
- muscles_wsgi-1.0.0/src/muscles/wsgi/__about__.py +6 -0
- muscles_wsgi-1.0.0/src/muscles/wsgi/__init__.py +57 -0
- muscles_wsgi-1.0.0/src/muscles/wsgi/app.py +59 -0
- muscles_wsgi-1.0.0/src/muscles/wsgi/assets/__init__.py +6 -0
- muscles_wsgi-1.0.0/src/muscles/wsgi/assets/asset.py +81 -0
- muscles_wsgi-1.0.0/src/muscles/wsgi/assets/axios.min.js +3 -0
- muscles_wsgi-1.0.0/src/muscles/wsgi/assets/vue.global.js +15934 -0
- muscles_wsgi-1.0.0/src/muscles/wsgi/providers.py +38 -0
- muscles_wsgi-1.0.0/src/muscles/wsgi/restful/__init__.py +27 -0
- muscles_wsgi-1.0.0/src/muscles/wsgi/restful/parameters.py +46 -0
- muscles_wsgi-1.0.0/src/muscles/wsgi/restful/request_body.py +58 -0
- muscles_wsgi-1.0.0/src/muscles/wsgi/restful/response_body.py +39 -0
- muscles_wsgi-1.0.0/src/muscles/wsgi/restful/restful.py +280 -0
- muscles_wsgi-1.0.0/src/muscles/wsgi/restful/swagger.py +290 -0
- muscles_wsgi-1.0.0/src/muscles/wsgi/restful/templates/swagger.jinja2 +38 -0
- muscles_wsgi-1.0.0/src/muscles/wsgi/template/__init__.py +10 -0
- muscles_wsgi-1.0.0/src/muscles/wsgi/template/template.py +464 -0
- muscles_wsgi-1.0.0/src/muscles/wsgi/testing.py +148 -0
- muscles_wsgi-1.0.0/src/muscles/wsgi/uwsgi/__init__.py +5 -0
- muscles_wsgi-1.0.0/src/muscles/wsgi/uwsgi/uwsgi.py +17 -0
- muscles_wsgi-1.0.0/src/muscles/wsgi/watchdog/__init__.py +6 -0
- muscles_wsgi-1.0.0/src/muscles/wsgi/watchdog/watchdog.py +140 -0
- muscles_wsgi-1.0.0/src/muscles/wsgi/wsgi/__init__.py +43 -0
- muscles_wsgi-1.0.0/src/muscles/wsgi/wsgi/actor.py +52 -0
- muscles_wsgi-1.0.0/src/muscles/wsgi/wsgi/error_handler.py +68 -0
- muscles_wsgi-1.0.0/src/muscles/wsgi/wsgi/http_code.py +397 -0
- muscles_wsgi-1.0.0/src/muscles/wsgi/wsgi/request.py +1047 -0
- muscles_wsgi-1.0.0/src/muscles/wsgi/wsgi/response.py +566 -0
- muscles_wsgi-1.0.0/src/muscles/wsgi/wsgi/routers.py +159 -0
- muscles_wsgi-1.0.0/src/muscles/wsgi/wsgi/server.py +667 -0
- muscles_wsgi-1.0.0/src/muscles/wsgi/wsgi/strategy.py +47 -0
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: muscles-wsgi
|
|
3
|
+
Version: 1.0.0
|
|
4
|
+
Summary: Muscles WSGI runtime adapter for Web/API applications
|
|
5
|
+
License: MIT
|
|
6
|
+
Author: Denis B.
|
|
7
|
+
Author-email: denis@butko.info
|
|
8
|
+
Requires-Python: >=3.10,<4.0
|
|
9
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
10
|
+
Classifier: Programming Language :: Python :: 3
|
|
11
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
12
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
13
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
14
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
15
|
+
Classifier: Programming Language :: Python :: 3.14
|
|
16
|
+
Provides-Extra: mime
|
|
17
|
+
Provides-Extra: server
|
|
18
|
+
Requires-Dist: dnspython (==2.6.1)
|
|
19
|
+
Requires-Dist: jinja2 (==3.1.2)
|
|
20
|
+
Requires-Dist: jsonschema (==4.16.0)
|
|
21
|
+
Requires-Dist: muscles (>=1.0.0rc1,<2.0.0)
|
|
22
|
+
Requires-Dist: python-magic (==0.4.27) ; extra == "mime"
|
|
23
|
+
Requires-Dist: requests (>=2.31.0,<3.0.0)
|
|
24
|
+
Requires-Dist: requests-toolbelt (>=1.0.0,<2.0.0)
|
|
25
|
+
Requires-Dist: uwsgi (==2.0.20) ; extra == "server"
|
|
26
|
+
Requires-Dist: watchdog (>=4.0.0,<5.0.0)
|
|
27
|
+
Description-Content-Type: text/markdown
|
|
28
|
+
|
|
29
|
+
# Muscles WSGI
|
|
30
|
+
|
|
31
|
+
`muscles-wsgi` is the WSGI runtime for Muscles. It provides page routing,
|
|
32
|
+
request/response handling, templates, static files, REST controllers and Swagger
|
|
33
|
+
UI on top of the shared `muscles` core.
|
|
34
|
+
|
|
35
|
+
## Installation
|
|
36
|
+
|
|
37
|
+
```bash
|
|
38
|
+
pip install muscles-wsgi
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
Canonical ecosystem install matrix is documented in core:
|
|
42
|
+
[Muscles installation matrix](https://github.com/butkoden/muscles/blob/master/docs/installation.md).
|
|
43
|
+
|
|
44
|
+
## Related Repositories
|
|
45
|
+
|
|
46
|
+
- [`muscles`](https://github.com/butkoden/muscles) - core contracts, routing, actions and canonical documentation.
|
|
47
|
+
- [`muscles-asgi`](https://github.com/butkoden/muscles-asgi) - ASGI runtime with the same application model.
|
|
48
|
+
- [`muscles-cli`](https://github.com/butkoden/muscles-cli) - CLI projection and developer commands.
|
|
49
|
+
- [`muscles-mcp`](https://github.com/butkoden/muscles-mcp) - MCP projection that can also expose WSGI/CLI adapters.
|
|
50
|
+
- [`muscles-benchmarks`](https://github.com/butkoden/muscles-benchmarks) - WSGI regression and architecture checks.
|
|
51
|
+
|
|
52
|
+
## Runtime
|
|
53
|
+
|
|
54
|
+
An app binds `Context` to `WsgiStrategy`:
|
|
55
|
+
|
|
56
|
+
```python
|
|
57
|
+
from muscles import ApplicationMeta, Configurator, Context
|
|
58
|
+
from muscles.wsgi import WsgiStrategy
|
|
59
|
+
|
|
60
|
+
|
|
61
|
+
class App(metaclass=ApplicationMeta):
|
|
62
|
+
config = Configurator(obj={"main": {"HOST": "0.0.0.0", "PORT": "8080"}})
|
|
63
|
+
context = Context(WsgiStrategy, params={})
|
|
64
|
+
|
|
65
|
+
def run(self, *args):
|
|
66
|
+
return self.context.execute(*args, shutup=True)
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
`WsgiStrategy` now accepts explicit `host` and `port` keyword arguments and uses
|
|
70
|
+
standard WSGI environment keys such as `PATH_INFO`, `QUERY_STRING` and
|
|
71
|
+
`wsgi.url_scheme`.
|
|
72
|
+
|
|
73
|
+
## Schema Ownership
|
|
74
|
+
|
|
75
|
+
WSGI does not ship its own `muscles.wsgi.schema_` package. Framework schemas,
|
|
76
|
+
columns, fields, request/response bodies, security objects and value objects
|
|
77
|
+
belong to `muscles.core.schema` and should be imported from `muscles`:
|
|
78
|
+
|
|
79
|
+
```python
|
|
80
|
+
from muscles import Column, JsonRequestBody, Model, String
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
## ASGI/WSGI Parity
|
|
84
|
+
|
|
85
|
+
WSGI mirrors the ASGI developer-facing API. An application should be able to
|
|
86
|
+
switch from `AsgiStrategy` to `WsgiStrategy` without changing route groups,
|
|
87
|
+
OpenAPI metadata, guards, auth overrides, response helpers, file upload
|
|
88
|
+
handlers or typed handler arguments.
|
|
89
|
+
|
|
90
|
+
The WSGI package also exposes the same convenience layers:
|
|
91
|
+
|
|
92
|
+
```python
|
|
93
|
+
from muscles.wsgi import MuscularWsgiApp, TestClient, wsgi_app
|
|
94
|
+
|
|
95
|
+
application = wsgi_app(MuscularWsgiApp())
|
|
96
|
+
client = TestClient(application).with_bearer("token")
|
|
97
|
+
response = client.post("/api/documents", json={"title": "Spec"})
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
Use `auth=False` on a route when a public endpoint such as `/api/login` lives
|
|
101
|
+
inside a protected API group.
|
|
102
|
+
|
|
103
|
+
## REST API And Swagger
|
|
104
|
+
|
|
105
|
+
`RestApi` registers controllers and actions into the shared route structure.
|
|
106
|
+
Swagger is generated from those controller schemas, request bodies, parameters
|
|
107
|
+
and response bodies.
|
|
108
|
+
|
|
109
|
+
The generated OpenAPI paths include the mounted API prefix. If a controller
|
|
110
|
+
action is registered as `/bookings` under prefix `/api/v1`, the schema exposes
|
|
111
|
+
`/api/v1/bookings`.
|
|
112
|
+
|
|
113
|
+
More detail: [docs/openapi-and-routing.md](docs/openapi-and-routing.md).
|
|
114
|
+
Backend pipeline features are documented in
|
|
115
|
+
[docs/backend-pipeline.md](docs/backend-pipeline.md).
|
|
116
|
+
Russian documentation:
|
|
117
|
+
[docs/openapi-and-routing.ru.md](docs/openapi-and-routing.ru.md) and
|
|
118
|
+
[docs/backend-pipeline.ru.md](docs/backend-pipeline.ru.md).
|
|
119
|
+
|
|
120
|
+
## Request Handling
|
|
121
|
+
|
|
122
|
+
The request parser supports standard WSGI input and does not require optional
|
|
123
|
+
system libraries to import. Multipart parsing uses the Python standard library;
|
|
124
|
+
`python-magic` is treated as optional.
|
|
125
|
+
|
|
126
|
+
WSGI strategy uses a persistent server lifecycle on strategy/app level, so
|
|
127
|
+
route cache is reused across requests while `environ`/`start_response` remain
|
|
128
|
+
strictly per-request state.
|
|
129
|
+
|
|
130
|
+
## Development
|
|
131
|
+
|
|
132
|
+
Run tests with sibling packages on `PYTHONPATH` when working from source:
|
|
133
|
+
|
|
134
|
+
```bash
|
|
135
|
+
PYTHONPATH=../muscles/src:src python -m pytest -q
|
|
136
|
+
```
|
|
137
|
+
|
|
138
|
+
Production notes: [docs/production.md](docs/production.md).
|
|
139
|
+
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
# Muscles WSGI
|
|
2
|
+
|
|
3
|
+
`muscles-wsgi` is the WSGI runtime for Muscles. It provides page routing,
|
|
4
|
+
request/response handling, templates, static files, REST controllers and Swagger
|
|
5
|
+
UI on top of the shared `muscles` core.
|
|
6
|
+
|
|
7
|
+
## Installation
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
pip install muscles-wsgi
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
Canonical ecosystem install matrix is documented in core:
|
|
14
|
+
[Muscles installation matrix](https://github.com/butkoden/muscles/blob/master/docs/installation.md).
|
|
15
|
+
|
|
16
|
+
## Related Repositories
|
|
17
|
+
|
|
18
|
+
- [`muscles`](https://github.com/butkoden/muscles) - core contracts, routing, actions and canonical documentation.
|
|
19
|
+
- [`muscles-asgi`](https://github.com/butkoden/muscles-asgi) - ASGI runtime with the same application model.
|
|
20
|
+
- [`muscles-cli`](https://github.com/butkoden/muscles-cli) - CLI projection and developer commands.
|
|
21
|
+
- [`muscles-mcp`](https://github.com/butkoden/muscles-mcp) - MCP projection that can also expose WSGI/CLI adapters.
|
|
22
|
+
- [`muscles-benchmarks`](https://github.com/butkoden/muscles-benchmarks) - WSGI regression and architecture checks.
|
|
23
|
+
|
|
24
|
+
## Runtime
|
|
25
|
+
|
|
26
|
+
An app binds `Context` to `WsgiStrategy`:
|
|
27
|
+
|
|
28
|
+
```python
|
|
29
|
+
from muscles import ApplicationMeta, Configurator, Context
|
|
30
|
+
from muscles.wsgi import WsgiStrategy
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
class App(metaclass=ApplicationMeta):
|
|
34
|
+
config = Configurator(obj={"main": {"HOST": "0.0.0.0", "PORT": "8080"}})
|
|
35
|
+
context = Context(WsgiStrategy, params={})
|
|
36
|
+
|
|
37
|
+
def run(self, *args):
|
|
38
|
+
return self.context.execute(*args, shutup=True)
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
`WsgiStrategy` now accepts explicit `host` and `port` keyword arguments and uses
|
|
42
|
+
standard WSGI environment keys such as `PATH_INFO`, `QUERY_STRING` and
|
|
43
|
+
`wsgi.url_scheme`.
|
|
44
|
+
|
|
45
|
+
## Schema Ownership
|
|
46
|
+
|
|
47
|
+
WSGI does not ship its own `muscles.wsgi.schema_` package. Framework schemas,
|
|
48
|
+
columns, fields, request/response bodies, security objects and value objects
|
|
49
|
+
belong to `muscles.core.schema` and should be imported from `muscles`:
|
|
50
|
+
|
|
51
|
+
```python
|
|
52
|
+
from muscles import Column, JsonRequestBody, Model, String
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
## ASGI/WSGI Parity
|
|
56
|
+
|
|
57
|
+
WSGI mirrors the ASGI developer-facing API. An application should be able to
|
|
58
|
+
switch from `AsgiStrategy` to `WsgiStrategy` without changing route groups,
|
|
59
|
+
OpenAPI metadata, guards, auth overrides, response helpers, file upload
|
|
60
|
+
handlers or typed handler arguments.
|
|
61
|
+
|
|
62
|
+
The WSGI package also exposes the same convenience layers:
|
|
63
|
+
|
|
64
|
+
```python
|
|
65
|
+
from muscles.wsgi import MuscularWsgiApp, TestClient, wsgi_app
|
|
66
|
+
|
|
67
|
+
application = wsgi_app(MuscularWsgiApp())
|
|
68
|
+
client = TestClient(application).with_bearer("token")
|
|
69
|
+
response = client.post("/api/documents", json={"title": "Spec"})
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
Use `auth=False` on a route when a public endpoint such as `/api/login` lives
|
|
73
|
+
inside a protected API group.
|
|
74
|
+
|
|
75
|
+
## REST API And Swagger
|
|
76
|
+
|
|
77
|
+
`RestApi` registers controllers and actions into the shared route structure.
|
|
78
|
+
Swagger is generated from those controller schemas, request bodies, parameters
|
|
79
|
+
and response bodies.
|
|
80
|
+
|
|
81
|
+
The generated OpenAPI paths include the mounted API prefix. If a controller
|
|
82
|
+
action is registered as `/bookings` under prefix `/api/v1`, the schema exposes
|
|
83
|
+
`/api/v1/bookings`.
|
|
84
|
+
|
|
85
|
+
More detail: [docs/openapi-and-routing.md](docs/openapi-and-routing.md).
|
|
86
|
+
Backend pipeline features are documented in
|
|
87
|
+
[docs/backend-pipeline.md](docs/backend-pipeline.md).
|
|
88
|
+
Russian documentation:
|
|
89
|
+
[docs/openapi-and-routing.ru.md](docs/openapi-and-routing.ru.md) and
|
|
90
|
+
[docs/backend-pipeline.ru.md](docs/backend-pipeline.ru.md).
|
|
91
|
+
|
|
92
|
+
## Request Handling
|
|
93
|
+
|
|
94
|
+
The request parser supports standard WSGI input and does not require optional
|
|
95
|
+
system libraries to import. Multipart parsing uses the Python standard library;
|
|
96
|
+
`python-magic` is treated as optional.
|
|
97
|
+
|
|
98
|
+
WSGI strategy uses a persistent server lifecycle on strategy/app level, so
|
|
99
|
+
route cache is reused across requests while `environ`/`start_response` remain
|
|
100
|
+
strictly per-request state.
|
|
101
|
+
|
|
102
|
+
## Development
|
|
103
|
+
|
|
104
|
+
Run tests with sibling packages on `PYTHONPATH` when working from source:
|
|
105
|
+
|
|
106
|
+
```bash
|
|
107
|
+
PYTHONPATH=../muscles/src:src python -m pytest -q
|
|
108
|
+
```
|
|
109
|
+
|
|
110
|
+
Production notes: [docs/production.md](docs/production.md).
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["poetry-core>=1.0.0"]
|
|
3
|
+
build-backend = "poetry.core.masonry.api"
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
[tool.poetry]
|
|
7
|
+
name = "muscles-wsgi"
|
|
8
|
+
version = "1.0.0"
|
|
9
|
+
description = "Muscles WSGI runtime adapter for Web/API applications"
|
|
10
|
+
readme = "README.md"
|
|
11
|
+
authors = ["Denis B. <denis@butko.info>"]
|
|
12
|
+
license = "MIT"
|
|
13
|
+
packages = [{include = "muscles", from = "src"}]
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
[tool.poetry.dependencies]
|
|
17
|
+
python = ">=3.10,<4.0"
|
|
18
|
+
muscles = ">=1.0.0rc1,<2.0.0"
|
|
19
|
+
watchdog = "^4.0.0"
|
|
20
|
+
uwsgi = {version = "==2.0.20", optional = true}
|
|
21
|
+
jinja2 = "==3.1.2"
|
|
22
|
+
jsonschema = "==4.16.0"
|
|
23
|
+
python-magic = {version = "==0.4.27", optional = true}
|
|
24
|
+
requests = "^2.31.0"
|
|
25
|
+
requests-toolbelt = "^1.0.0"
|
|
26
|
+
dnspython = "==2.6.1"
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
[tool.poetry.dev-dependencies]
|
|
30
|
+
pytest = "==7.1.3"
|
|
31
|
+
setuptools = "==69.0.2"
|
|
32
|
+
|
|
33
|
+
[tool.poetry.extras]
|
|
34
|
+
server = ["uwsgi"]
|
|
35
|
+
mime = ["python-magic"]
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
# Makefile
|
|
2
|
+
|
|
3
|
+
start:
|
|
4
|
+
docker-compose up -d
|
|
5
|
+
docker exec -it butkoinfo_core_1 bash
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
stop:
|
|
9
|
+
docker-compose up -d
|
|
10
|
+
docker exec -it butkoinfo-core-1 bash
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
console:
|
|
14
|
+
docker exec -it butkoinfo_core_1 bash
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
logs:
|
|
18
|
+
docker-compose logs
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
develop:
|
|
22
|
+
#docker exec -it butkoinfo_core_1 pipenv install
|
|
23
|
+
pipenv run python setup.py develop
|
|
24
|
+
pipenv install
|
|
25
|
+
|
|
26
|
+
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
from .wsgi import *
|
|
2
|
+
from .watchdog import *
|
|
3
|
+
from .uwsgi import *
|
|
4
|
+
from .template import Template
|
|
5
|
+
from .template import *
|
|
6
|
+
from .restful import *
|
|
7
|
+
from .assets import *
|
|
8
|
+
from .app import MuscularWsgiApp, wsgi_app
|
|
9
|
+
from .providers import WsgiGeneratorProvider
|
|
10
|
+
from .testing import TestClient, TestResponse
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
__all__ = (
|
|
14
|
+
"Asset",
|
|
15
|
+
"RestApi",
|
|
16
|
+
"TemplateLoader",
|
|
17
|
+
"Filters",
|
|
18
|
+
"Template",
|
|
19
|
+
"UwsgiReload",
|
|
20
|
+
"Watchdog",
|
|
21
|
+
"PatternMatchingHandler",
|
|
22
|
+
"ResponseErrorHandler",
|
|
23
|
+
"WsgiStrategy",
|
|
24
|
+
"ImproperBodyPartContentException",
|
|
25
|
+
"NonMultipartContentTypeException",
|
|
26
|
+
"BodyPart",
|
|
27
|
+
"FileStorage",
|
|
28
|
+
"FieldStorage",
|
|
29
|
+
"Request",
|
|
30
|
+
"Response",
|
|
31
|
+
"BadResponse",
|
|
32
|
+
"BaseResponse",
|
|
33
|
+
"MakeResponse",
|
|
34
|
+
"JsonResponse",
|
|
35
|
+
"HtmlResponse",
|
|
36
|
+
"code_status",
|
|
37
|
+
"Transport",
|
|
38
|
+
"WsgiTransport",
|
|
39
|
+
"WsgiServer",
|
|
40
|
+
"RouteRule",
|
|
41
|
+
"RouteRuleDefault",
|
|
42
|
+
"RouteRuleVar",
|
|
43
|
+
"RouteRuleInt",
|
|
44
|
+
"RouteRuleFloat",
|
|
45
|
+
"Itinerary",
|
|
46
|
+
"Node",
|
|
47
|
+
"Routes",
|
|
48
|
+
"Api",
|
|
49
|
+
"api",
|
|
50
|
+
"routes",
|
|
51
|
+
"itinerary",
|
|
52
|
+
"MuscularWsgiApp",
|
|
53
|
+
"wsgi_app",
|
|
54
|
+
"WsgiGeneratorProvider",
|
|
55
|
+
"TestClient",
|
|
56
|
+
"TestResponse",
|
|
57
|
+
)
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
3
|
+
from typing import Any, cast
|
|
4
|
+
|
|
5
|
+
from muscles import ApplicationMeta, Configurator, Context
|
|
6
|
+
from .wsgi import WsgiStrategy
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
class MuscularWsgiApp(metaclass=ApplicationMeta):
|
|
10
|
+
"""
|
|
11
|
+
Minimal WSGI-oriented Muscles application skeleton.
|
|
12
|
+
Projects can subclass this class and register routes/controllers in app code.
|
|
13
|
+
"""
|
|
14
|
+
|
|
15
|
+
package_paths = []
|
|
16
|
+
shutup = False
|
|
17
|
+
|
|
18
|
+
config = Configurator(
|
|
19
|
+
obj={
|
|
20
|
+
"main": {
|
|
21
|
+
"BASEDIR": ".",
|
|
22
|
+
"BASE_URL": "http://localhost:8080",
|
|
23
|
+
"SERVER_NAME": "localhost:8080",
|
|
24
|
+
"HOST": "0.0.0.0",
|
|
25
|
+
"PORT": "8080",
|
|
26
|
+
"ENV": "development",
|
|
27
|
+
"DEBUG": True,
|
|
28
|
+
"TIMEZONE": "UTC",
|
|
29
|
+
"MAIN_ROUTE": "page.index",
|
|
30
|
+
},
|
|
31
|
+
"routes": {"prefix": ""},
|
|
32
|
+
"api": {"prefix": "/api", "default_version": "v1", "controllers": {}},
|
|
33
|
+
}
|
|
34
|
+
)
|
|
35
|
+
|
|
36
|
+
wsgi = Context(cast(Any, WsgiStrategy), params={})
|
|
37
|
+
|
|
38
|
+
def run(self, *args, **kwargs):
|
|
39
|
+
return self.wsgi.execute(*args, **kwargs, shutup=self.shutup)
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
def wsgi_app(app: MuscularWsgiApp, context: str | Context | None = None):
|
|
43
|
+
def _resolve_context():
|
|
44
|
+
if isinstance(context, Context):
|
|
45
|
+
return context
|
|
46
|
+
if context is not None and hasattr(app, context):
|
|
47
|
+
selected = getattr(app, context)
|
|
48
|
+
if not isinstance(selected, Context):
|
|
49
|
+
raise TypeError(f"Application has no context '{context}'")
|
|
50
|
+
return selected
|
|
51
|
+
if hasattr(app, 'wsgi'):
|
|
52
|
+
return getattr(app, 'wsgi')
|
|
53
|
+
raise TypeError("Application has no context 'wsgi'")
|
|
54
|
+
|
|
55
|
+
def application(environ, start_response):
|
|
56
|
+
ctx = _resolve_context()
|
|
57
|
+
return ctx.execute(environ=environ, start_response=start_response)
|
|
58
|
+
|
|
59
|
+
return application
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import hashlib
|
|
2
|
+
from ..wsgi.routers import routes
|
|
3
|
+
import os
|
|
4
|
+
import muscles.core
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
class Asset:
|
|
8
|
+
|
|
9
|
+
_installed = {}
|
|
10
|
+
_instances = {}
|
|
11
|
+
_initialized = False
|
|
12
|
+
|
|
13
|
+
def __call__(self, *args, **kwargs):
|
|
14
|
+
"""
|
|
15
|
+
Данная реализация не учитывает возможное изменение передаваемых
|
|
16
|
+
аргументов в `__init__`
|
|
17
|
+
|
|
18
|
+
:param args:
|
|
19
|
+
:param kwargs:
|
|
20
|
+
:return:
|
|
21
|
+
"""
|
|
22
|
+
return self
|
|
23
|
+
|
|
24
|
+
def __init__(self):
|
|
25
|
+
if self.__class__._initialized:
|
|
26
|
+
return
|
|
27
|
+
path = os.path.dirname(os.path.abspath(muscles.core.__file__))
|
|
28
|
+
routes.add_static('/'.join([path, 'assets']), prefix='/mus', full_path=True)
|
|
29
|
+
self.__class__._initialized = True
|
|
30
|
+
|
|
31
|
+
def add(self, tag=None, file=None, body=None, id=None, dependency=None):
|
|
32
|
+
hash = hashlib.sha256()
|
|
33
|
+
if id is not None:
|
|
34
|
+
pass
|
|
35
|
+
elif id is None and file is not None:
|
|
36
|
+
hash.update(file.encode('utf8'))
|
|
37
|
+
id = hash.hexdigest()
|
|
38
|
+
elif id is None and body is not None:
|
|
39
|
+
hash.update(body.encode('utf8'))
|
|
40
|
+
id = hash.hexdigest()
|
|
41
|
+
|
|
42
|
+
if tag not in self._installed:
|
|
43
|
+
self._installed[tag] = {}
|
|
44
|
+
|
|
45
|
+
if id not in self._installed[tag]:
|
|
46
|
+
self._installed[tag][id] = {
|
|
47
|
+
'id': id,
|
|
48
|
+
'tag': tag,
|
|
49
|
+
'file': file,
|
|
50
|
+
'body': body,
|
|
51
|
+
'installed': False,
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
def compile(self, tag=None):
|
|
55
|
+
if tag is None:
|
|
56
|
+
raise ValueError('Tag not set for compile options')
|
|
57
|
+
if tag == 'js':
|
|
58
|
+
return self.js_compile()
|
|
59
|
+
elif tag == 'style':
|
|
60
|
+
return self.style_compile()
|
|
61
|
+
|
|
62
|
+
def js_compile(self):
|
|
63
|
+
_list = []
|
|
64
|
+
if 'js' in self._installed:
|
|
65
|
+
for id in self._installed['js']:
|
|
66
|
+
self._installed['js'][id]['installed'] = True
|
|
67
|
+
block = self._installed['js'][id]
|
|
68
|
+
_list.append('<script src="' + block['file'] + '"></script>')
|
|
69
|
+
return "\n".join(_list)
|
|
70
|
+
|
|
71
|
+
def style_compile(self):
|
|
72
|
+
_list = []
|
|
73
|
+
if 'style' in self._installed:
|
|
74
|
+
for id in self._installed['style']:
|
|
75
|
+
self._installed['style'][id]['installed'] = True
|
|
76
|
+
block = self._installed['style'][id]
|
|
77
|
+
_list.append('<link href="' + block['file'] + '" rel="stylesheet">')
|
|
78
|
+
return "\n".join(_list)
|
|
79
|
+
|
|
80
|
+
|
|
81
|
+
asset = Asset()
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
/* axios v0.27.2 | (c) 2022 by Matt Zabriskie */
|
|
2
|
+
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.axios=t():e.axios=t()}(this,(function(){return function(e){var t={};function n(r){if(t[r])return t[r].exports;var o=t[r]={i:r,l:!1,exports:{}};return e[r].call(o.exports,o,o.exports,n),o.l=!0,o.exports}return n.m=e,n.c=t,n.d=function(e,t,r){n.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:r})},n.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},n.t=function(e,t){if(1&t&&(e=n(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var r=Object.create(null);if(n.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var o in e)n.d(r,o,function(t){return e[t]}.bind(null,o));return r},n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,"a",t),t},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},n.p="",n(n.s=13)}([function(e,t,n){"use strict";var r,o=n(4),i=Object.prototype.toString,s=(r=Object.create(null),function(e){var t=i.call(e);return r[t]||(r[t]=t.slice(8,-1).toLowerCase())});function a(e){return e=e.toLowerCase(),function(t){return s(t)===e}}function u(e){return Array.isArray(e)}function c(e){return void 0===e}var f=a("ArrayBuffer");function l(e){return null!==e&&"object"==typeof e}function p(e){if("object"!==s(e))return!1;var t=Object.getPrototypeOf(e);return null===t||t===Object.prototype}var d=a("Date"),h=a("File"),m=a("Blob"),v=a("FileList");function y(e){return"[object Function]"===i.call(e)}var g=a("URLSearchParams");function E(e,t){if(null!=e)if("object"!=typeof e&&(e=[e]),u(e))for(var n=0,r=e.length;n<r;n++)t.call(null,e[n],n,e);else for(var o in e)Object.prototype.hasOwnProperty.call(e,o)&&t.call(null,e[o],o,e)}var b,O=(b="undefined"!=typeof Uint8Array&&Object.getPrototypeOf(Uint8Array),function(e){return b&&e instanceof b});e.exports={isArray:u,isArrayBuffer:f,isBuffer:function(e){return null!==e&&!c(e)&&null!==e.constructor&&!c(e.constructor)&&"function"==typeof e.constructor.isBuffer&&e.constructor.isBuffer(e)},isFormData:function(e){return e&&("function"==typeof FormData&&e instanceof FormData||"[object FormData]"===i.call(e)||y(e.toString)&&"[object FormData]"===e.toString())},isArrayBufferView:function(e){return"undefined"!=typeof ArrayBuffer&&ArrayBuffer.isView?ArrayBuffer.isView(e):e&&e.buffer&&f(e.buffer)},isString:function(e){return"string"==typeof e},isNumber:function(e){return"number"==typeof e},isObject:l,isPlainObject:p,isUndefined:c,isDate:d,isFile:h,isBlob:m,isFunction:y,isStream:function(e){return l(e)&&y(e.pipe)},isURLSearchParams:g,isStandardBrowserEnv:function(){return("undefined"==typeof navigator||"ReactNative"!==navigator.product&&"NativeScript"!==navigator.product&&"NS"!==navigator.product)&&("undefined"!=typeof window&&"undefined"!=typeof document)},forEach:E,merge:function e(){var t={};function n(n,r){p(t[r])&&p(n)?t[r]=e(t[r],n):p(n)?t[r]=e({},n):u(n)?t[r]=n.slice():t[r]=n}for(var r=0,o=arguments.length;r<o;r++)E(arguments[r],n);return t},extend:function(e,t,n){return E(t,(function(t,r){e[r]=n&&"function"==typeof t?o(t,n):t})),e},trim:function(e){return e.trim?e.trim():e.replace(/^\s+|\s+$/g,"")},stripBOM:function(e){return 65279===e.charCodeAt(0)&&(e=e.slice(1)),e},inherits:function(e,t,n,r){e.prototype=Object.create(t.prototype,r),e.prototype.constructor=e,n&&Object.assign(e.prototype,n)},toFlatObject:function(e,t,n){var r,o,i,s={};t=t||{};do{for(o=(r=Object.getOwnPropertyNames(e)).length;o-- >0;)s[i=r[o]]||(t[i]=e[i],s[i]=!0);e=Object.getPrototypeOf(e)}while(e&&(!n||n(e,t))&&e!==Object.prototype);return t},kindOf:s,kindOfTest:a,endsWith:function(e,t,n){e=String(e),(void 0===n||n>e.length)&&(n=e.length),n-=t.length;var r=e.indexOf(t,n);return-1!==r&&r===n},toArray:function(e){if(!e)return null;var t=e.length;if(c(t))return null;for(var n=new Array(t);t-- >0;)n[t]=e[t];return n},isTypedArray:O,isFileList:v}},function(e,t,n){"use strict";var r=n(0);function o(e,t,n,r,o){Error.call(this),this.message=e,this.name="AxiosError",t&&(this.code=t),n&&(this.config=n),r&&(this.request=r),o&&(this.response=o)}r.inherits(o,Error,{toJSON:function(){return{message:this.message,name:this.name,description:this.description,number:this.number,fileName:this.fileName,lineNumber:this.lineNumber,columnNumber:this.columnNumber,stack:this.stack,config:this.config,code:this.code,status:this.response&&this.response.status?this.response.status:null}}});var i=o.prototype,s={};["ERR_BAD_OPTION_VALUE","ERR_BAD_OPTION","ECONNABORTED","ETIMEDOUT","ERR_NETWORK","ERR_FR_TOO_MANY_REDIRECTS","ERR_DEPRECATED","ERR_BAD_RESPONSE","ERR_BAD_REQUEST","ERR_CANCELED"].forEach((function(e){s[e]={value:e}})),Object.defineProperties(o,s),Object.defineProperty(i,"isAxiosError",{value:!0}),o.from=function(e,t,n,s,a,u){var c=Object.create(i);return r.toFlatObject(e,c,(function(e){return e!==Error.prototype})),o.call(c,e.message,t,n,s,a),c.name=e.name,u&&Object.assign(c,u),c},e.exports=o},function(e,t,n){"use strict";var r=n(1);function o(e){r.call(this,null==e?"canceled":e,r.ERR_CANCELED),this.name="CanceledError"}n(0).inherits(o,r,{__CANCEL__:!0}),e.exports=o},function(e,t,n){"use strict";var r=n(0),o=n(19),i=n(1),s=n(6),a=n(7),u={"Content-Type":"application/x-www-form-urlencoded"};function c(e,t){!r.isUndefined(e)&&r.isUndefined(e["Content-Type"])&&(e["Content-Type"]=t)}var f,l={transitional:s,adapter:(("undefined"!=typeof XMLHttpRequest||"undefined"!=typeof process&&"[object process]"===Object.prototype.toString.call(process))&&(f=n(8)),f),transformRequest:[function(e,t){if(o(t,"Accept"),o(t,"Content-Type"),r.isFormData(e)||r.isArrayBuffer(e)||r.isBuffer(e)||r.isStream(e)||r.isFile(e)||r.isBlob(e))return e;if(r.isArrayBufferView(e))return e.buffer;if(r.isURLSearchParams(e))return c(t,"application/x-www-form-urlencoded;charset=utf-8"),e.toString();var n,i=r.isObject(e),s=t&&t["Content-Type"];if((n=r.isFileList(e))||i&&"multipart/form-data"===s){var u=this.env&&this.env.FormData;return a(n?{"files[]":e}:e,u&&new u)}return i||"application/json"===s?(c(t,"application/json"),function(e,t,n){if(r.isString(e))try{return(t||JSON.parse)(e),r.trim(e)}catch(e){if("SyntaxError"!==e.name)throw e}return(n||JSON.stringify)(e)}(e)):e}],transformResponse:[function(e){var t=this.transitional||l.transitional,n=t&&t.silentJSONParsing,o=t&&t.forcedJSONParsing,s=!n&&"json"===this.responseType;if(s||o&&r.isString(e)&&e.length)try{return JSON.parse(e)}catch(e){if(s){if("SyntaxError"===e.name)throw i.from(e,i.ERR_BAD_RESPONSE,this,null,this.response);throw e}}return e}],timeout:0,xsrfCookieName:"XSRF-TOKEN",xsrfHeaderName:"X-XSRF-TOKEN",maxContentLength:-1,maxBodyLength:-1,env:{FormData:n(27)},validateStatus:function(e){return e>=200&&e<300},headers:{common:{Accept:"application/json, text/plain, */*"}}};r.forEach(["delete","get","head"],(function(e){l.headers[e]={}})),r.forEach(["post","put","patch"],(function(e){l.headers[e]=r.merge(u)})),e.exports=l},function(e,t,n){"use strict";e.exports=function(e,t){return function(){for(var n=new Array(arguments.length),r=0;r<n.length;r++)n[r]=arguments[r];return e.apply(t,n)}}},function(e,t,n){"use strict";var r=n(0);function o(e){return encodeURIComponent(e).replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+").replace(/%5B/gi,"[").replace(/%5D/gi,"]")}e.exports=function(e,t,n){if(!t)return e;var i;if(n)i=n(t);else if(r.isURLSearchParams(t))i=t.toString();else{var s=[];r.forEach(t,(function(e,t){null!=e&&(r.isArray(e)?t+="[]":e=[e],r.forEach(e,(function(e){r.isDate(e)?e=e.toISOString():r.isObject(e)&&(e=JSON.stringify(e)),s.push(o(t)+"="+o(e))})))})),i=s.join("&")}if(i){var a=e.indexOf("#");-1!==a&&(e=e.slice(0,a)),e+=(-1===e.indexOf("?")?"?":"&")+i}return e}},function(e,t,n){"use strict";e.exports={silentJSONParsing:!0,forcedJSONParsing:!0,clarifyTimeoutError:!1}},function(e,t,n){"use strict";var r=n(0);e.exports=function(e,t){t=t||new FormData;var n=[];function o(e){return null===e?"":r.isDate(e)?e.toISOString():r.isArrayBuffer(e)||r.isTypedArray(e)?"function"==typeof Blob?new Blob([e]):Buffer.from(e):e}return function e(i,s){if(r.isPlainObject(i)||r.isArray(i)){if(-1!==n.indexOf(i))throw Error("Circular reference detected in "+s);n.push(i),r.forEach(i,(function(n,i){if(!r.isUndefined(n)){var a,u=s?s+"."+i:i;if(n&&!s&&"object"==typeof n)if(r.endsWith(i,"{}"))n=JSON.stringify(n);else if(r.endsWith(i,"[]")&&(a=r.toArray(n)))return void a.forEach((function(e){!r.isUndefined(e)&&t.append(u,o(e))}));e(n,u)}})),n.pop()}else t.append(s,o(i))}(e),t}},function(e,t,n){"use strict";var r=n(0),o=n(20),i=n(21),s=n(5),a=n(9),u=n(24),c=n(25),f=n(6),l=n(1),p=n(2),d=n(26);e.exports=function(e){return new Promise((function(t,n){var h,m=e.data,v=e.headers,y=e.responseType;function g(){e.cancelToken&&e.cancelToken.unsubscribe(h),e.signal&&e.signal.removeEventListener("abort",h)}r.isFormData(m)&&r.isStandardBrowserEnv()&&delete v["Content-Type"];var E=new XMLHttpRequest;if(e.auth){var b=e.auth.username||"",O=e.auth.password?unescape(encodeURIComponent(e.auth.password)):"";v.Authorization="Basic "+btoa(b+":"+O)}var x=a(e.baseURL,e.url);function w(){if(E){var r="getAllResponseHeaders"in E?u(E.getAllResponseHeaders()):null,i={data:y&&"text"!==y&&"json"!==y?E.response:E.responseText,status:E.status,statusText:E.statusText,headers:r,config:e,request:E};o((function(e){t(e),g()}),(function(e){n(e),g()}),i),E=null}}if(E.open(e.method.toUpperCase(),s(x,e.params,e.paramsSerializer),!0),E.timeout=e.timeout,"onloadend"in E?E.onloadend=w:E.onreadystatechange=function(){E&&4===E.readyState&&(0!==E.status||E.responseURL&&0===E.responseURL.indexOf("file:"))&&setTimeout(w)},E.onabort=function(){E&&(n(new l("Request aborted",l.ECONNABORTED,e,E)),E=null)},E.onerror=function(){n(new l("Network Error",l.ERR_NETWORK,e,E,E)),E=null},E.ontimeout=function(){var t=e.timeout?"timeout of "+e.timeout+"ms exceeded":"timeout exceeded",r=e.transitional||f;e.timeoutErrorMessage&&(t=e.timeoutErrorMessage),n(new l(t,r.clarifyTimeoutError?l.ETIMEDOUT:l.ECONNABORTED,e,E)),E=null},r.isStandardBrowserEnv()){var R=(e.withCredentials||c(x))&&e.xsrfCookieName?i.read(e.xsrfCookieName):void 0;R&&(v[e.xsrfHeaderName]=R)}"setRequestHeader"in E&&r.forEach(v,(function(e,t){void 0===m&&"content-type"===t.toLowerCase()?delete v[t]:E.setRequestHeader(t,e)})),r.isUndefined(e.withCredentials)||(E.withCredentials=!!e.withCredentials),y&&"json"!==y&&(E.responseType=e.responseType),"function"==typeof e.onDownloadProgress&&E.addEventListener("progress",e.onDownloadProgress),"function"==typeof e.onUploadProgress&&E.upload&&E.upload.addEventListener("progress",e.onUploadProgress),(e.cancelToken||e.signal)&&(h=function(e){E&&(n(!e||e&&e.type?new p:e),E.abort(),E=null)},e.cancelToken&&e.cancelToken.subscribe(h),e.signal&&(e.signal.aborted?h():e.signal.addEventListener("abort",h))),m||(m=null);var S=d(x);S&&-1===["http","https","file"].indexOf(S)?n(new l("Unsupported protocol "+S+":",l.ERR_BAD_REQUEST,e)):E.send(m)}))}},function(e,t,n){"use strict";var r=n(22),o=n(23);e.exports=function(e,t){return e&&!r(t)?o(e,t):t}},function(e,t,n){"use strict";e.exports=function(e){return!(!e||!e.__CANCEL__)}},function(e,t,n){"use strict";var r=n(0);e.exports=function(e,t){t=t||{};var n={};function o(e,t){return r.isPlainObject(e)&&r.isPlainObject(t)?r.merge(e,t):r.isPlainObject(t)?r.merge({},t):r.isArray(t)?t.slice():t}function i(n){return r.isUndefined(t[n])?r.isUndefined(e[n])?void 0:o(void 0,e[n]):o(e[n],t[n])}function s(e){if(!r.isUndefined(t[e]))return o(void 0,t[e])}function a(n){return r.isUndefined(t[n])?r.isUndefined(e[n])?void 0:o(void 0,e[n]):o(void 0,t[n])}function u(n){return n in t?o(e[n],t[n]):n in e?o(void 0,e[n]):void 0}var c={url:s,method:s,data:s,baseURL:a,transformRequest:a,transformResponse:a,paramsSerializer:a,timeout:a,timeoutMessage:a,withCredentials:a,adapter:a,responseType:a,xsrfCookieName:a,xsrfHeaderName:a,onUploadProgress:a,onDownloadProgress:a,decompress:a,maxContentLength:a,maxBodyLength:a,beforeRedirect:a,transport:a,httpAgent:a,httpsAgent:a,cancelToken:a,socketPath:a,responseEncoding:a,validateStatus:u};return r.forEach(Object.keys(e).concat(Object.keys(t)),(function(e){var t=c[e]||i,o=t(e);r.isUndefined(o)&&t!==u||(n[e]=o)})),n}},function(e,t){e.exports={version:"0.27.2"}},function(e,t,n){e.exports=n(14)},function(e,t,n){"use strict";var r=n(0),o=n(4),i=n(15),s=n(11);var a=function e(t){var n=new i(t),a=o(i.prototype.request,n);return r.extend(a,i.prototype,n),r.extend(a,n),a.create=function(n){return e(s(t,n))},a}(n(3));a.Axios=i,a.CanceledError=n(2),a.CancelToken=n(29),a.isCancel=n(10),a.VERSION=n(12).version,a.toFormData=n(7),a.AxiosError=n(1),a.Cancel=a.CanceledError,a.all=function(e){return Promise.all(e)},a.spread=n(30),a.isAxiosError=n(31),e.exports=a,e.exports.default=a},function(e,t,n){"use strict";var r=n(0),o=n(5),i=n(16),s=n(17),a=n(11),u=n(9),c=n(28),f=c.validators;function l(e){this.defaults=e,this.interceptors={request:new i,response:new i}}l.prototype.request=function(e,t){"string"==typeof e?(t=t||{}).url=e:t=e||{},(t=a(this.defaults,t)).method?t.method=t.method.toLowerCase():this.defaults.method?t.method=this.defaults.method.toLowerCase():t.method="get";var n=t.transitional;void 0!==n&&c.assertOptions(n,{silentJSONParsing:f.transitional(f.boolean),forcedJSONParsing:f.transitional(f.boolean),clarifyTimeoutError:f.transitional(f.boolean)},!1);var r=[],o=!0;this.interceptors.request.forEach((function(e){"function"==typeof e.runWhen&&!1===e.runWhen(t)||(o=o&&e.synchronous,r.unshift(e.fulfilled,e.rejected))}));var i,u=[];if(this.interceptors.response.forEach((function(e){u.push(e.fulfilled,e.rejected)})),!o){var l=[s,void 0];for(Array.prototype.unshift.apply(l,r),l=l.concat(u),i=Promise.resolve(t);l.length;)i=i.then(l.shift(),l.shift());return i}for(var p=t;r.length;){var d=r.shift(),h=r.shift();try{p=d(p)}catch(e){h(e);break}}try{i=s(p)}catch(e){return Promise.reject(e)}for(;u.length;)i=i.then(u.shift(),u.shift());return i},l.prototype.getUri=function(e){e=a(this.defaults,e);var t=u(e.baseURL,e.url);return o(t,e.params,e.paramsSerializer)},r.forEach(["delete","get","head","options"],(function(e){l.prototype[e]=function(t,n){return this.request(a(n||{},{method:e,url:t,data:(n||{}).data}))}})),r.forEach(["post","put","patch"],(function(e){function t(t){return function(n,r,o){return this.request(a(o||{},{method:e,headers:t?{"Content-Type":"multipart/form-data"}:{},url:n,data:r}))}}l.prototype[e]=t(),l.prototype[e+"Form"]=t(!0)})),e.exports=l},function(e,t,n){"use strict";var r=n(0);function o(){this.handlers=[]}o.prototype.use=function(e,t,n){return this.handlers.push({fulfilled:e,rejected:t,synchronous:!!n&&n.synchronous,runWhen:n?n.runWhen:null}),this.handlers.length-1},o.prototype.eject=function(e){this.handlers[e]&&(this.handlers[e]=null)},o.prototype.forEach=function(e){r.forEach(this.handlers,(function(t){null!==t&&e(t)}))},e.exports=o},function(e,t,n){"use strict";var r=n(0),o=n(18),i=n(10),s=n(3),a=n(2);function u(e){if(e.cancelToken&&e.cancelToken.throwIfRequested(),e.signal&&e.signal.aborted)throw new a}e.exports=function(e){return u(e),e.headers=e.headers||{},e.data=o.call(e,e.data,e.headers,e.transformRequest),e.headers=r.merge(e.headers.common||{},e.headers[e.method]||{},e.headers),r.forEach(["delete","get","head","post","put","patch","common"],(function(t){delete e.headers[t]})),(e.adapter||s.adapter)(e).then((function(t){return u(e),t.data=o.call(e,t.data,t.headers,e.transformResponse),t}),(function(t){return i(t)||(u(e),t&&t.response&&(t.response.data=o.call(e,t.response.data,t.response.headers,e.transformResponse))),Promise.reject(t)}))}},function(e,t,n){"use strict";var r=n(0),o=n(3);e.exports=function(e,t,n){var i=this||o;return r.forEach(n,(function(n){e=n.call(i,e,t)})),e}},function(e,t,n){"use strict";var r=n(0);e.exports=function(e,t){r.forEach(e,(function(n,r){r!==t&&r.toUpperCase()===t.toUpperCase()&&(e[t]=n,delete e[r])}))}},function(e,t,n){"use strict";var r=n(1);e.exports=function(e,t,n){var o=n.config.validateStatus;n.status&&o&&!o(n.status)?t(new r("Request failed with status code "+n.status,[r.ERR_BAD_REQUEST,r.ERR_BAD_RESPONSE][Math.floor(n.status/100)-4],n.config,n.request,n)):e(n)}},function(e,t,n){"use strict";var r=n(0);e.exports=r.isStandardBrowserEnv()?{write:function(e,t,n,o,i,s){var a=[];a.push(e+"="+encodeURIComponent(t)),r.isNumber(n)&&a.push("expires="+new Date(n).toGMTString()),r.isString(o)&&a.push("path="+o),r.isString(i)&&a.push("domain="+i),!0===s&&a.push("secure"),document.cookie=a.join("; ")},read:function(e){var t=document.cookie.match(new RegExp("(^|;\\s*)("+e+")=([^;]*)"));return t?decodeURIComponent(t[3]):null},remove:function(e){this.write(e,"",Date.now()-864e5)}}:{write:function(){},read:function(){return null},remove:function(){}}},function(e,t,n){"use strict";e.exports=function(e){return/^([a-z][a-z\d+\-.]*:)?\/\//i.test(e)}},function(e,t,n){"use strict";e.exports=function(e,t){return t?e.replace(/\/+$/,"")+"/"+t.replace(/^\/+/,""):e}},function(e,t,n){"use strict";var r=n(0),o=["age","authorization","content-length","content-type","etag","expires","from","host","if-modified-since","if-unmodified-since","last-modified","location","max-forwards","proxy-authorization","referer","retry-after","user-agent"];e.exports=function(e){var t,n,i,s={};return e?(r.forEach(e.split("\n"),(function(e){if(i=e.indexOf(":"),t=r.trim(e.substr(0,i)).toLowerCase(),n=r.trim(e.substr(i+1)),t){if(s[t]&&o.indexOf(t)>=0)return;s[t]="set-cookie"===t?(s[t]?s[t]:[]).concat([n]):s[t]?s[t]+", "+n:n}})),s):s}},function(e,t,n){"use strict";var r=n(0);e.exports=r.isStandardBrowserEnv()?function(){var e,t=/(msie|trident)/i.test(navigator.userAgent),n=document.createElement("a");function o(e){var r=e;return t&&(n.setAttribute("href",r),r=n.href),n.setAttribute("href",r),{href:n.href,protocol:n.protocol?n.protocol.replace(/:$/,""):"",host:n.host,search:n.search?n.search.replace(/^\?/,""):"",hash:n.hash?n.hash.replace(/^#/,""):"",hostname:n.hostname,port:n.port,pathname:"/"===n.pathname.charAt(0)?n.pathname:"/"+n.pathname}}return e=o(window.location.href),function(t){var n=r.isString(t)?o(t):t;return n.protocol===e.protocol&&n.host===e.host}}():function(){return!0}},function(e,t,n){"use strict";e.exports=function(e){var t=/^([-+\w]{1,25})(:?\/\/|:)/.exec(e);return t&&t[1]||""}},function(e,t){e.exports=null},function(e,t,n){"use strict";var r=n(12).version,o=n(1),i={};["object","boolean","number","function","string","symbol"].forEach((function(e,t){i[e]=function(n){return typeof n===e||"a"+(t<1?"n ":" ")+e}}));var s={};i.transitional=function(e,t,n){function i(e,t){return"[Axios v"+r+"] Transitional option '"+e+"'"+t+(n?". "+n:"")}return function(n,r,a){if(!1===e)throw new o(i(r," has been removed"+(t?" in "+t:"")),o.ERR_DEPRECATED);return t&&!s[r]&&(s[r]=!0,console.warn(i(r," has been deprecated since v"+t+" and will be removed in the near future"))),!e||e(n,r,a)}},e.exports={assertOptions:function(e,t,n){if("object"!=typeof e)throw new o("options must be an object",o.ERR_BAD_OPTION_VALUE);for(var r=Object.keys(e),i=r.length;i-- >0;){var s=r[i],a=t[s];if(a){var u=e[s],c=void 0===u||a(u,s,e);if(!0!==c)throw new o("option "+s+" must be "+c,o.ERR_BAD_OPTION_VALUE)}else if(!0!==n)throw new o("Unknown option "+s,o.ERR_BAD_OPTION)}},validators:i}},function(e,t,n){"use strict";var r=n(2);function o(e){if("function"!=typeof e)throw new TypeError("executor must be a function.");var t;this.promise=new Promise((function(e){t=e}));var n=this;this.promise.then((function(e){if(n._listeners){var t,r=n._listeners.length;for(t=0;t<r;t++)n._listeners[t](e);n._listeners=null}})),this.promise.then=function(e){var t,r=new Promise((function(e){n.subscribe(e),t=e})).then(e);return r.cancel=function(){n.unsubscribe(t)},r},e((function(e){n.reason||(n.reason=new r(e),t(n.reason))}))}o.prototype.throwIfRequested=function(){if(this.reason)throw this.reason},o.prototype.subscribe=function(e){this.reason?e(this.reason):this._listeners?this._listeners.push(e):this._listeners=[e]},o.prototype.unsubscribe=function(e){if(this._listeners){var t=this._listeners.indexOf(e);-1!==t&&this._listeners.splice(t,1)}},o.source=function(){var e;return{token:new o((function(t){e=t})),cancel:e}},e.exports=o},function(e,t,n){"use strict";e.exports=function(e){return function(t){return e.apply(null,t)}}},function(e,t,n){"use strict";var r=n(0);e.exports=function(e){return r.isObject(e)&&!0===e.isAxiosError}}])}));
|
|
3
|
+
//# sourceMappingURL=axios.min.map
|