oe-python-template-example 0.0.4__py3-none-any.whl → 0.0.8__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_example/api.py +87 -0
- oe_python_template_example/cli.py +33 -0
- {oe_python_template_example-0.0.4.dist-info → oe_python_template_example-0.0.8.dist-info}/METADATA +14 -8
- oe_python_template_example-0.0.8.dist-info/RECORD +10 -0
- oe_python_template_example-0.0.4.dist-info/RECORD +0 -9
- {oe_python_template_example-0.0.4.dist-info → oe_python_template_example-0.0.8.dist-info}/WHEEL +0 -0
- {oe_python_template_example-0.0.4.dist-info → oe_python_template_example-0.0.8.dist-info}/entry_points.txt +0 -0
- {oe_python_template_example-0.0.4.dist-info → oe_python_template_example-0.0.8.dist-info}/licenses/LICENSE +0 -0
@@ -0,0 +1,87 @@
|
|
1
|
+
"""FastAPI application with REST API endpoints.
|
2
|
+
|
3
|
+
This module provides a FastAPI application with several endpoints:
|
4
|
+
- A hello-world endpoint that returns a greeting message
|
5
|
+
- An echo endpoint that echoes back the provided text
|
6
|
+
|
7
|
+
The endpoints use Pydantic models for request and response validation.
|
8
|
+
"""
|
9
|
+
|
10
|
+
from fastapi import FastAPI
|
11
|
+
from pydantic import BaseModel, Field
|
12
|
+
|
13
|
+
from oe_python_template_example import Service
|
14
|
+
|
15
|
+
HELLO_WORLD_EXAMPLE = "Hello, world!"
|
16
|
+
|
17
|
+
|
18
|
+
app = FastAPI(
|
19
|
+
version="1.0.0",
|
20
|
+
title="OE Python Template Example",
|
21
|
+
contact={
|
22
|
+
"name": "Helmut Hoffer von Ankershoffen",
|
23
|
+
"email": "helmuthva@gmail.com",
|
24
|
+
"url": "https://github.com/helmut-hoffer-von-ankershoffen",
|
25
|
+
},
|
26
|
+
terms_of_service="https://oe-python-template-example.readthedocs.io/en/latest/",
|
27
|
+
)
|
28
|
+
|
29
|
+
|
30
|
+
class HelloWorldResponse(BaseModel):
|
31
|
+
"""Response model for hello-world endpoint."""
|
32
|
+
|
33
|
+
message: str = Field(
|
34
|
+
...,
|
35
|
+
description="The hello world message",
|
36
|
+
examples=[HELLO_WORLD_EXAMPLE],
|
37
|
+
)
|
38
|
+
|
39
|
+
|
40
|
+
class EchoResponse(BaseModel):
|
41
|
+
"""Response model for echo endpoint."""
|
42
|
+
|
43
|
+
message: str = Field(
|
44
|
+
...,
|
45
|
+
min_length=1,
|
46
|
+
description="The message content",
|
47
|
+
examples=[HELLO_WORLD_EXAMPLE],
|
48
|
+
)
|
49
|
+
|
50
|
+
|
51
|
+
class EchoRequest(BaseModel):
|
52
|
+
"""Request model for echo endpoint."""
|
53
|
+
|
54
|
+
text: str = Field(
|
55
|
+
...,
|
56
|
+
min_length=1,
|
57
|
+
description="The text to echo back",
|
58
|
+
examples=[HELLO_WORLD_EXAMPLE],
|
59
|
+
)
|
60
|
+
|
61
|
+
|
62
|
+
@app.get("/hello-world", tags=["Basics"])
|
63
|
+
async def hello_world() -> HelloWorldResponse:
|
64
|
+
"""
|
65
|
+
Return a hello world message.
|
66
|
+
|
67
|
+
Returns:
|
68
|
+
HelloWorldResponse: A response containing the hello world message.
|
69
|
+
"""
|
70
|
+
return HelloWorldResponse(message=Service.get_hello_world())
|
71
|
+
|
72
|
+
|
73
|
+
@app.post("/echo", tags=["Basics"])
|
74
|
+
async def echo(request: EchoRequest) -> EchoResponse:
|
75
|
+
"""
|
76
|
+
Echo back the provided text.
|
77
|
+
|
78
|
+
Args:
|
79
|
+
request (EchoRequest): The request containing the text to echo back.
|
80
|
+
|
81
|
+
Returns:
|
82
|
+
EchoResponse: A response containing the echoed text.
|
83
|
+
|
84
|
+
Raises:
|
85
|
+
422 Unprocessable Entity: If text is not provided or empty.
|
86
|
+
"""
|
87
|
+
return EchoResponse(message=request.text)
|
@@ -3,9 +3,12 @@
|
|
3
3
|
from typing import Annotated
|
4
4
|
|
5
5
|
import typer
|
6
|
+
import uvicorn
|
7
|
+
import yaml
|
6
8
|
from rich.console import Console
|
7
9
|
|
8
10
|
from oe_python_template_example import Service, __version__
|
11
|
+
from oe_python_template_example.api import app as api
|
9
12
|
|
10
13
|
console = Console()
|
11
14
|
|
@@ -37,6 +40,36 @@ def hello_world() -> None:
|
|
37
40
|
console.print(Service.get_hello_world())
|
38
41
|
|
39
42
|
|
43
|
+
@cli.command()
|
44
|
+
def serve(
|
45
|
+
host: Annotated[str, typer.Option(help="Host to bind the server to")] = "127.0.0.1",
|
46
|
+
port: Annotated[int, typer.Option(help="Port to bind the server to")] = 8000,
|
47
|
+
reload: Annotated[bool, typer.Option(help="Enable auto-reload")] = True,
|
48
|
+
) -> None:
|
49
|
+
"""Start the API server."""
|
50
|
+
console.print(f"Starting API server at http://{host}:{port}")
|
51
|
+
uvicorn.run(
|
52
|
+
"oe_python_template_example.api:app",
|
53
|
+
host=host,
|
54
|
+
port=port,
|
55
|
+
reload=reload,
|
56
|
+
)
|
57
|
+
|
58
|
+
|
59
|
+
@cli.command()
|
60
|
+
def openapi(
|
61
|
+
output_format: Annotated[
|
62
|
+
str, typer.Option(help="Output format (yaml or json), defaults to yaml", case_sensitive=False)
|
63
|
+
] = "yaml",
|
64
|
+
) -> None:
|
65
|
+
"""Dump the OpenAPI specification to stdout (YAML by default)."""
|
66
|
+
schema = api.openapi()
|
67
|
+
if output_format.lower() == "json":
|
68
|
+
console.print_json(data=schema)
|
69
|
+
else:
|
70
|
+
console.print(yaml.dump(schema, default_flow_style=False), end="")
|
71
|
+
|
72
|
+
|
40
73
|
def _apply_cli_settings(cli: typer.Typer, epilog: str) -> None:
|
41
74
|
"""Add epilog to all typers in the tree and configure default behavior."""
|
42
75
|
cli.info.epilog = epilog
|
{oe_python_template_example-0.0.4.dist-info → oe_python_template_example-0.0.8.dist-info}/METADATA
RENAMED
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.4
|
2
2
|
Name: oe-python-template-example
|
3
|
-
Version: 0.0.
|
3
|
+
Version: 0.0.8
|
4
4
|
Summary: 🧠 Example project scaffolded and kept up to date with OE Python Template (oe-python-template).
|
5
5
|
Project-URL: Homepage, https://oe-python-template-example.readthedocs.io/en/latest/
|
6
6
|
Project-URL: Documentation, https://oe-python-template-example.readthedocs.io/en/latest/
|
@@ -30,7 +30,7 @@ License: MIT License
|
|
30
30
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
31
31
|
SOFTWARE.
|
32
32
|
License-File: LICENSE
|
33
|
-
Keywords: codecov,docker,oe-python-template-example,pydantic,python,ruff,typer,uv
|
33
|
+
Keywords: act,codecov,copier,cyclonedx,detect-secrets,devcontainer,docker,git-cliff,jupyter,marimo,mypy,nox,oe-python-template,oe-python-template-example,pip-audit,pip-licenses,pre-commit,pydantic,pypi,pytest,python,readthedocs,ruff,sonarcloud,sonarqube,sphinx,streamlit,typer,uv
|
34
34
|
Classifier: Development Status :: 2 - Pre-Alpha
|
35
35
|
Classifier: Framework :: Pydantic
|
36
36
|
Classifier: Framework :: Pytest
|
@@ -48,13 +48,15 @@ Classifier: Programming Language :: Python :: 3.12
|
|
48
48
|
Classifier: Programming Language :: Python :: 3.13
|
49
49
|
Classifier: Typing :: Typed
|
50
50
|
Requires-Python: <4.0,>=3.11
|
51
|
+
Requires-Dist: fastapi[all,standard]>=0.115.11
|
51
52
|
Requires-Dist: pydantic>=2.10.6
|
52
53
|
Requires-Dist: python-dotenv>=1.0.1
|
53
54
|
Requires-Dist: typer>=0.15.1
|
54
55
|
Provides-Extra: examples
|
56
|
+
Requires-Dist: jinja2>=3.1.6; extra == 'examples'
|
55
57
|
Requires-Dist: jupyter>=1.1.1; extra == 'examples'
|
56
|
-
Requires-Dist: marimo>=0.11.
|
57
|
-
Requires-Dist: streamlit>=1.
|
58
|
+
Requires-Dist: marimo>=0.11.17; extra == 'examples'
|
59
|
+
Requires-Dist: streamlit>=1.43.1; extra == 'examples'
|
58
60
|
Description-Content-Type: text/markdown
|
59
61
|
|
60
62
|
# 🧠 OE Python Template Example
|
@@ -71,13 +73,17 @@ Description-Content-Type: text/markdown
|
|
71
73
|
[](https://sonarcloud.io/summary/new_code?id=helmut-hoffer-von-ankershoffen_oe-python-template-example)
|
72
74
|
[](https://codecov.io/gh/helmut-hoffer-von-ankershoffen/oe-python-template-example)
|
73
75
|
[](https://github.com/helmut-hoffer-von-ankershoffen/oe-python-template-example/blob/main/noxfile.py)
|
76
|
+
[](https://github.com/helmut-hoffer-von-ankershoffen/oe-python-template-example/blob/main/noxfile.py)
|
74
77
|
[](https://github.com/helmut-hoffer-von-ankershoffen/oe-python-template-example/releases)
|
75
78
|
[](https://github.com/helmut-hoffer-von-ankershoffen/oe-python-template-example/commits/main/)
|
76
79
|
[](https://pypi.python.org/pypi/oe-python-template-example)
|
77
80
|
[](https://pypi.python.org/pypi/oe-python-template-example)
|
78
81
|
[](https://hub.docker.com/r/helmuthva/oe-python-template-example/tags)
|
79
|
-
[](https://hub.docker.com/r/helmuthva/oe-python-template-example/)
|
80
83
|
[](https://github.com/helmut-hoffer-von-ankershoffen/oe-python-template)
|
84
|
+
[](https://vscode.dev/redirect?url=vscode://ms-vscode-remote.remote-containers/cloneInVolume?url=https://github.com/helmut-hoffer-von-ankershoffen/oe-python-template-example)
|
85
|
+
[](https://github.com/codespaces/new/helmut-hoffer-von-ankershoffen/oe-python-template-example)
|
86
|
+
|
81
87
|
<!---
|
82
88
|
[](https://github.com/helmut-hoffer-von-ankershoffen/oe-python-template-example/pkgs/container/oe-python-template-example)
|
83
89
|
[](https://github.com/helmut-hoffer-von-ankershoffen/oe-python-template-example/pkgs/container/oe-python-template-example)
|
@@ -122,7 +128,7 @@ copier copy gh:helmut-hoffer-von-ankershoffen/oe-python-template .
|
|
122
128
|
Step 4: Setup the local environment
|
123
129
|
|
124
130
|
```shell
|
125
|
-
uv run nox -s
|
131
|
+
uv run nox -s setup_dev
|
126
132
|
```
|
127
133
|
|
128
134
|
Step 5: Perform inital commit and push
|
@@ -169,8 +175,8 @@ uvx oe-python-template-example
|
|
169
175
|
The CLI provides extensive help:
|
170
176
|
|
171
177
|
```shell
|
172
|
-
uvx oe-python-template-example --help
|
173
|
-
uvx oe-python-template-example
|
178
|
+
uvx oe-python-template-example --help # all CLI commands
|
179
|
+
uvx oe-python-template-example hello-world --help # help for specific command
|
174
180
|
```
|
175
181
|
|
176
182
|
|
@@ -0,0 +1,10 @@
|
|
1
|
+
oe_python_template_example/__init__.py,sha256=-sCwS9lD6CvgWw88f7snBDF947PWIhEupJVebXL_w1M,314
|
2
|
+
oe_python_template_example/api.py,sha256=3OmZFB_5bVdHS6wcGttfgiOmq86K5R6lXOzvTPXIQ94,2203
|
3
|
+
oe_python_template_example/cli.py,sha256=ptgFKScjYQAj364TCBqs23rVZqIpXUxUXEoc_4f1YJE,2399
|
4
|
+
oe_python_template_example/constants.py,sha256=6uQHr2CRgzWQWhUQCRRKiPuFhzKB2iblZk3dIRQ5dDc,358
|
5
|
+
oe_python_template_example/service.py,sha256=ZpsZFnnJm_3EqoVqGomfAyIjLVmWJFuJ3G9qatWj5yI,516
|
6
|
+
oe_python_template_example-0.0.8.dist-info/METADATA,sha256=E5qbQjBSvgDTEqxceoqIYvOMjekUwGc3LRUXYWEmxI4,20031
|
7
|
+
oe_python_template_example-0.0.8.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
|
8
|
+
oe_python_template_example-0.0.8.dist-info/entry_points.txt,sha256=S2eCPB45b1Wgj_GsDRFAN-e4h7dBA5UPxT8od98erDE,82
|
9
|
+
oe_python_template_example-0.0.8.dist-info/licenses/LICENSE,sha256=5H409K6xzz9U5eUaoAHQExNkoWJRlU0LEj6wL2QJ34s,1113
|
10
|
+
oe_python_template_example-0.0.8.dist-info/RECORD,,
|
@@ -1,9 +0,0 @@
|
|
1
|
-
oe_python_template_example/__init__.py,sha256=-sCwS9lD6CvgWw88f7snBDF947PWIhEupJVebXL_w1M,314
|
2
|
-
oe_python_template_example/cli.py,sha256=6giUEesoEuwytZnthiTBH9-ALkiwdkTL4TEb7vsqbGM,1351
|
3
|
-
oe_python_template_example/constants.py,sha256=6uQHr2CRgzWQWhUQCRRKiPuFhzKB2iblZk3dIRQ5dDc,358
|
4
|
-
oe_python_template_example/service.py,sha256=ZpsZFnnJm_3EqoVqGomfAyIjLVmWJFuJ3G9qatWj5yI,516
|
5
|
-
oe_python_template_example-0.0.4.dist-info/METADATA,sha256=-pexoz-5o86urvLccP2wWgrm1s29wUIIgPZDWyuUEnc,18808
|
6
|
-
oe_python_template_example-0.0.4.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
|
7
|
-
oe_python_template_example-0.0.4.dist-info/entry_points.txt,sha256=S2eCPB45b1Wgj_GsDRFAN-e4h7dBA5UPxT8od98erDE,82
|
8
|
-
oe_python_template_example-0.0.4.dist-info/licenses/LICENSE,sha256=5H409K6xzz9U5eUaoAHQExNkoWJRlU0LEj6wL2QJ34s,1113
|
9
|
-
oe_python_template_example-0.0.4.dist-info/RECORD,,
|
{oe_python_template_example-0.0.4.dist-info → oe_python_template_example-0.0.8.dist-info}/WHEEL
RENAMED
File without changes
|
File without changes
|
File without changes
|