Trigon
A batteries-included python web framework
🚀 Getting started
Attention: The project is a work in progress and should not be used in production 🚧
Installing trigon can be done as such:
pip install trigon
The project's documentation can be found here.
from typing import Any, Dict
import uvicorn
from trigon.core.controller import Controller, http, route
from trigon.core.controller.result import Ok, Result
from trigon.trigon import trigon
class ItemService:
def get_items(self) -> list[Dict[str, Any]]:
return [
{
"id": 1,
"name": "Product 1",
"description": "This is the description for Product 1.",
"price": 19.99,
"category": "Electronics",
"stock": 50,
},
{
"id": 2,
"name": "Product 2",
"description": "A sample description for Product 2.",
"price": 29.99,
"category": "Clothing",
"stock": 100,
},
{
"id": 3,
"name": "Product 3",
"description": "Description for Product 3 goes here.",
"price": 9.99,
"category": "Books",
"stock": 25,
},
]
class ItemController(Controller):
def __init__(self, service: ItemService) -> None:
self.service = service
@route.get("/")
@http.status(Ok)
async def get_items(self) -> Result[list[Dict[str, Any]]]:
return Ok(self.service.get_items())
if __name__ == "__main__":
app = (
trigon()
.build_container(lambda builder: builder.singleton(ItemService))
.register_controllers(ItemController)
.configure_logging(
lambda builder: builder.override("uvicorn")
.register_middleware()
.add_console_handler()
.add_file_handler("logs/{time}.log"),
)
.build()
)
uvicorn.run(app, host="0.0.0.0", port=8000)
For a more elaborate example (controller discovery, database configuration, Repository-Service Pattern, etc.) check out Example 02.
✨ Contributing
If you would like to contribute to the project, please go through the Contributing Guidelines first. In order to locally set up the project please follow the instructions below:
# Set up the GitHub repository
git clone https://github.com/billsioros/trigon.git
# Create a virtual environment using poetry and install the required dependencies
poetry shell
poetry install
# Install pre-commit hooks
pre-commit install --install-hooks
Alternatively, you can support the project by Buying me a ☕.
Metadata
Release files for trigon 0.2.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| trigon-0.2.0.tar.gz | 16.2 kB | Without provenance | Details for trigon-0.2.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| trigon-0.2.0-py3-none-any.whl | Python 3 | none | any | Details for trigon-0.2.0-py3-none-any.whl |
Total release size: 36.8 kB
Release files / trigon-0.2.0.tar.gz
| Download URL | trigon-0.2.0.tar.gz |
|---|---|
| Size | 16.2 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
9b52066036f89229083245cdbcd6b889cfb58d5c6792bd68603253f5b8bde476
|
|
BLAKE2b-256 checksum How to use checksums |
a58eb8a9f967ab62f437474e6958e358c01f2e92b456c0cf59ac68817a0a238e
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.8.0 pkginfo/1.9.6 readme-renderer/42.0 requests/2.31.0 requests-toolbelt/1.0.0 urllib3/2.0.4 tqdm/4.66.1 importlib-metadata/6.8.0 keyring/24.2.0 rfc3986/2.0.0 colorama/0.4.6 CPython/3.10.13
|
Release files / trigon-0.2.0-py3-none-any.whl
| Download URL | trigon-0.2.0-py3-none-any.whl |
|---|---|
| Size | 20.6 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
4bfd41dd5b8e1edc893ffb785764d30a637718c63ca80c412c389b3518e929be
|
|
BLAKE2b-256 checksum How to use checksums |
ddbbf66ebd192c1b811a511d04f2ea3721f6bacd59764fab574b1ef1dc17b11c
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.8.0 pkginfo/1.9.6 readme-renderer/42.0 requests/2.31.0 requests-toolbelt/1.0.0 urllib3/2.0.4 tqdm/4.66.1 importlib-metadata/6.8.0 keyring/24.2.0 rfc3986/2.0.0 colorama/0.4.6 CPython/3.10.13
|
Security for trigon 0.2.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.