A prototypical application framework for Python.
Project description
⚠️ Note: This framework is still in the alpha release stage. Expect potential changes and improvements in future releases.
py-application-framework
A prototypical application framework for Python.
Features:
- Builder Pattern: The framework incorporates the builder pattern to facilitate the assembly of a Host that accommodates multiple Applications. This approach ensures a structured and efficient setup process.
Compatibility
The library is compatible with the following Python versions:
- 3.7, 3.8, 3.9, 3.10, 3.11, 3.12
Installation
$ pip install py-application-framework
Quick Start
Here's a quick example to get you started:
# examples/single_app/main.py
import os
from application_framework.application.builder import ApplicationBuilder
from application_framework.config.builder import ConfigBuilder
from application_framework.host.builder import HostBuilder
from application_framework.host.restart_policy import RestartPolicy
from examples.single_app.config import Config
def main():
config = (
ConfigBuilder()
.set_environment_profile(env=os.getenv("APP_ENV", "development"))
.add_yaml_file(path="config.common.yaml")
.add_profiled_file(template="config.{profile}.yaml")
.add_prefixed_env_vars(prefix="CFG_", section_separator=".")
.set_type_conversion('host.port', int)
.set_type_conversion('app.port', int)
.bind(Config)
.build()
)
application = (
ApplicationBuilder()
.set_config(config)
.set_root_directory(".")
.use_entry_point("app:run")
.run_in_separate_process()
.add_http_route(path="/app/?.*", port=config.app.port)
.add_websocket_route(path="/app/ws/?.*", port=config.app.port + 9)
.build()
)
host = (
HostBuilder()
.add_application(application)
.set_restart_policy(RestartPolicy.ExponentialBackoff)
.set_listening_port(config.host.port)
.build()
)
host.run()
if __name__ == "__main__":
main()
Documentation
For more advanced usage and examples, please visit our readthedocs page.
License
py-application-framework
is released under the GPL 3 license. See LICENSE for more details.
Source Code
You can find the source code for py-application-framework
on GitHub.
Release Notes
1.0.0-alpha.2 (2024-06-07)
- Initial alpha release.
- ConfigBuilder: Introduces a flexible and extensible way to handle application configuration, supporting multiple sources such as YAML, JSON, INI, and environment variables, with type conversion and binding capabilities. Configurations can be overridden from multiple sources to provide maximum flexibility.
- Basic Documentation: An initial set of documentation is provided, giving users an introduction to the library.
- License: Released under the GPL 3 license.
This README reflects the current state of the project and will be updated with new features and improvements in future releases. Stay tuned for updates!
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Hashes for py-application-framework-1.0.0a2.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 896a144283edd56ac682ed0e89ea4914c4218dca9476831bcfd7ffd45d815ad6 |
|
MD5 | a0bd30a42fcad44dbc10d0f0c1d52aac |
|
BLAKE2b-256 | ced6e9dc9ef10807323a9612c7c0b3f32e2df2519836027fe1eb47ef22cc53c7 |
Hashes for py_application_framework-1.0.0a2-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 41faa8b0562be6adc98f1253ce8927fec6d6251b40e84b7445b915eb075a64f4 |
|
MD5 | 1e45cdb0593122e6bdac88fac5c4732b |
|
BLAKE2b-256 | 30c79d34d574b3cafc20c4558d229990b289dfee5c97464d9ef03c15ce35c261 |