oe-python-template 0.4.2__py3-none-any.whl → 0.4.4__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.
- oe_python_template/api.py +11 -2
- oe_python_template/cli.py +3 -0
- {oe_python_template-0.4.2.dist-info → oe_python_template-0.4.4.dist-info}/METADATA +7 -8
- oe_python_template-0.4.4.dist-info/RECORD +10 -0
- oe_python_template-0.4.2.dist-info/RECORD +0 -10
- {oe_python_template-0.4.2.dist-info → oe_python_template-0.4.4.dist-info}/WHEEL +0 -0
- {oe_python_template-0.4.2.dist-info → oe_python_template-0.4.4.dist-info}/entry_points.txt +0 -0
- {oe_python_template-0.4.2.dist-info → oe_python_template-0.4.4.dist-info}/licenses/LICENSE +0 -0
oe_python_template/api.py
CHANGED
|
@@ -8,6 +8,7 @@ This module provides a webservice API with several endpoints:
|
|
|
8
8
|
The endpoints use Pydantic models for request and response validation.
|
|
9
9
|
"""
|
|
10
10
|
|
|
11
|
+
import os
|
|
11
12
|
from collections.abc import Generator
|
|
12
13
|
from enum import StrEnum
|
|
13
14
|
from typing import Annotated
|
|
@@ -18,6 +19,8 @@ from pydantic import BaseModel, Field
|
|
|
18
19
|
from oe_python_template import Service
|
|
19
20
|
|
|
20
21
|
HELLO_WORLD_EXAMPLE = "Hello, world!"
|
|
22
|
+
UVICORN_HOST = os.environ.get("UVICORN_HOST", "127.0.0.1")
|
|
23
|
+
UVICORN_PORT = os.environ.get("UVICORN_PORT", "8000")
|
|
21
24
|
|
|
22
25
|
|
|
23
26
|
def get_service() -> Generator[Service, None, None]:
|
|
@@ -47,12 +50,18 @@ api = FastAPI(
|
|
|
47
50
|
{
|
|
48
51
|
"name": "v1",
|
|
49
52
|
"description": "API version 1, check link on the right",
|
|
50
|
-
"externalDocs": {
|
|
53
|
+
"externalDocs": {
|
|
54
|
+
"description": "sub-docs",
|
|
55
|
+
"url": f"http://{UVICORN_HOST}:{UVICORN_PORT}/api/v1/docs",
|
|
56
|
+
},
|
|
51
57
|
},
|
|
52
58
|
{
|
|
53
59
|
"name": "v2",
|
|
54
60
|
"description": "API version 2, check link on the right",
|
|
55
|
-
"externalDocs": {
|
|
61
|
+
"externalDocs": {
|
|
62
|
+
"description": "sub-docs",
|
|
63
|
+
"url": f"http://{UVICORN_HOST}:{UVICORN_PORT}/api/v2/docs",
|
|
64
|
+
},
|
|
56
65
|
},
|
|
57
66
|
],
|
|
58
67
|
)
|
oe_python_template/cli.py
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
"""CLI (Command Line Interface) of OE Python Template."""
|
|
2
2
|
|
|
3
|
+
import os
|
|
3
4
|
from enum import StrEnum
|
|
4
5
|
from typing import Annotated
|
|
5
6
|
|
|
@@ -49,6 +50,8 @@ def serve(
|
|
|
49
50
|
) -> None:
|
|
50
51
|
"""Start the API server."""
|
|
51
52
|
console.print(f"Starting API server at http://{host}:{port}")
|
|
53
|
+
os.environ["UVICORN_HOST"] = host
|
|
54
|
+
os.environ["UVICORN_PORT"] = str(port)
|
|
52
55
|
uvicorn.run(
|
|
53
56
|
"oe_python_template.api:api",
|
|
54
57
|
host=host,
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: oe-python-template
|
|
3
|
-
Version: 0.4.
|
|
3
|
+
Version: 0.4.4
|
|
4
4
|
Summary: 🧠 Copier template to scaffold Python projects compliant with best practices and modern tooling.
|
|
5
5
|
Project-URL: Homepage, https://oe-python-template.readthedocs.io/en/latest/
|
|
6
6
|
Project-URL: Documentation, https://oe-python-template.readthedocs.io/en/latest/
|
|
@@ -91,6 +91,7 @@ Description-Content-Type: text/markdown
|
|
|
91
91
|
|
|
92
92
|
> [!TIP]
|
|
93
93
|
> 📚 [Online documentation](https://oe-python-template.readthedocs.io/en/latest/) - 📖 [PDF Manual](https://oe-python-template.readthedocs.io/_/downloads/en/latest/pdf/)
|
|
94
|
+
|
|
94
95
|
---
|
|
95
96
|
|
|
96
97
|
|
|
@@ -172,16 +173,14 @@ Executing the command line interface (CLI) in an isolated Python environment is
|
|
|
172
173
|
```shell
|
|
173
174
|
uvx oe-python-template hello-world # prints "Hello, world! [..]"
|
|
174
175
|
uvx oe-python-template serve # serves webservice API
|
|
176
|
+
uvx oe-python-template serve --port=4711 # serves webservice API on port 4711
|
|
175
177
|
```
|
|
176
178
|
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
```shell
|
|
179
|
+
Notes:
|
|
180
|
+
* The API is versioned, mounted at ```/api/v1``` resp. ```/api/v2```
|
|
181
|
+
* While serving the webservice API go to [http://127.0.0.1:8000/api/v1/hello-world](http://127.0.0.1:8000/api/v1/hello-world) to see the respons of the ```hello-world``` operation.
|
|
182
|
+
* Interactive documentation is provided at [http://127.0.0.1:8000/api/docs](http://127.0.0.1:8000/api/docs)
|
|
183
183
|
|
|
184
|
-
When running the webservice API, goto http://127.0.0.1:8000/api/v1/docs
|
|
185
184
|
|
|
186
185
|
The CLI provides extensive help:
|
|
187
186
|
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
oe_python_template/__init__.py,sha256=XJAycUgDI2K8T0jVcXbaGfx2UAQJZbYcvJ_SYSqFyDA,315
|
|
2
|
+
oe_python_template/api.py,sha256=vhaIde8FHv5ZqdT9ZMzE_jVzn0f-801-nCiBZBWsoKU,6583
|
|
3
|
+
oe_python_template/cli.py,sha256=jvIPeJzx9esff7-M5pBe2R3vvmpxRvxKIre1VOGndls,3426
|
|
4
|
+
oe_python_template/constants.py,sha256=Z1c06l5DeRuFxYVLHihHHTYvr8_Qh0nyzVKOe5X3ZNs,350
|
|
5
|
+
oe_python_template/service.py,sha256=Gd-B9IIZ1vB1uONVJHA65hPnfeYeKUIcnU3rZbU2lGs,744
|
|
6
|
+
oe_python_template-0.4.4.dist-info/METADATA,sha256=ZBUR3N-sMhKZ9Pe_F6srGSFG6rCCiQMCgHCJwCl0oDA,21021
|
|
7
|
+
oe_python_template-0.4.4.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
|
|
8
|
+
oe_python_template-0.4.4.dist-info/entry_points.txt,sha256=IroSSWhLGxus9rxcashkYQda39TTvf7LbUMYtOKXUBE,66
|
|
9
|
+
oe_python_template-0.4.4.dist-info/licenses/LICENSE,sha256=5H409K6xzz9U5eUaoAHQExNkoWJRlU0LEj6wL2QJ34s,1113
|
|
10
|
+
oe_python_template-0.4.4.dist-info/RECORD,,
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
oe_python_template/__init__.py,sha256=XJAycUgDI2K8T0jVcXbaGfx2UAQJZbYcvJ_SYSqFyDA,315
|
|
2
|
-
oe_python_template/api.py,sha256=Yg_mrPGKvI123c41sR94Yx9NulPMuC90H4-nIMKJmKo,6292
|
|
3
|
-
oe_python_template/cli.py,sha256=ySbE8e5Igh3oNlLLJdfipKRDoReHfBquyJKBf6RhHyg,3335
|
|
4
|
-
oe_python_template/constants.py,sha256=Z1c06l5DeRuFxYVLHihHHTYvr8_Qh0nyzVKOe5X3ZNs,350
|
|
5
|
-
oe_python_template/service.py,sha256=Gd-B9IIZ1vB1uONVJHA65hPnfeYeKUIcnU3rZbU2lGs,744
|
|
6
|
-
oe_python_template-0.4.2.dist-info/METADATA,sha256=TfYWXXfXGAnMhHO8yzYpar3gLFB3iYjOACunP1Rd5gg,21004
|
|
7
|
-
oe_python_template-0.4.2.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
|
|
8
|
-
oe_python_template-0.4.2.dist-info/entry_points.txt,sha256=IroSSWhLGxus9rxcashkYQda39TTvf7LbUMYtOKXUBE,66
|
|
9
|
-
oe_python_template-0.4.2.dist-info/licenses/LICENSE,sha256=5H409K6xzz9U5eUaoAHQExNkoWJRlU0LEj6wL2QJ34s,1113
|
|
10
|
-
oe_python_template-0.4.2.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|