olympus-framework


Nameolympus-framework JSON
Version 0.1.1 PyPI version JSON
download
home_pageNone
SummaryA Python web framework foundation inspired by Laravel's routing, middleware, and exception handling.
upload_time2024-12-19 20:09:50
maintainerNone
docs_urlNone
authorNone
requires_python>=3.8
licenseMIT
keywords web framework routing middleware http jinja2
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            
# Olympus

![Latest Version](https://img.shields.io/pypi/v/olympus-framework)
![Downloads](https://img.shields.io/pypi/dm/olympus-framework)
![Status](https://img.shields.io/badge/status-alpha-orange)
![License: MIT](https://img.shields.io/badge/License-MIT-lightgrey.svg)

**Olympus** is a Python web framework foundation inspired by the rich routing, middleware, and exception handling systems found in Laravel. It provides a clean, extensible base that you can build upon for full-stack applications, whether you're serving HTML, JSON-based APIs, or file downloads. With Olympus, you can define routes using decorators, group them, apply middlewares globally or at the route level, and handle exceptions elegantly.

[Click here for the documentation](https://github.com/altxriainc/olympus/wiki)

---

## 🚀 Key Features

- **Expressive Routing System**: Define routes via decorators, including route groups, URL parameters, and multiple HTTP methods.
- **Advanced Middleware Support**: Apply middleware globally, per route, or per group. Handle pre- and post-request logic easily.
- **Exception Handling & Custom 404**: Gracefully handle errors and register custom exception handlers, including global 404 responses.
- **HTTPS Enforcement**: Force HTTPS globally or on specific routes/groups with a single middleware.
- **CORS Integration**: Easily add CORS headers to your responses, handle preflight requests.
- **JSON, File, and HTML Responses**: Return JSON APIs, serve files for download, or integrate a templating engine for HTML rendering.
- **Group Prefixes & Middleware Inheritance**: Organize routes into groups that share a prefix, middleware stack, or both.
- **Extensible & Composable**: Olympus is designed as a foundational layer. Plug in your own ORM, templating engine, or validation library.

---

## 🛠️ Getting Started

### Step 1: Install Olympus

Install Olympus via pip:

```bash
pip install olympus-framework
```

*(Ensure you have Python 3.8+ available.)*

### Step 2: Define Your First Route

Create a `main.py`:

```python
from src.server import run_server
from src.routing.decorators import route
from src.routing.response import Response
from src.routing.router import Router
from src.exceptions_manager import ExceptionsManager
from src.routing.exceptions import HttpNotFoundException

router = Router.get_instance()
exceptions_manager = ExceptionsManager()
router.set_exceptions_manager(exceptions_manager)

def handle_not_found(exc, request):
    return Response(status=404, body="Page not found!")
exceptions_manager.register_handler(HttpNotFoundException, handle_not_found)

@route("/hello", methods=["GET"])
def hello_route(request):
    return {"message": "Hello from Olympus!"}

if __name__ == "__main__":
    run_server("0.0.0.0", 8000)
```

Now, open [http://localhost:8000/hello](http://localhost:8000/hello) in your browser.

### Step 3: Use Middlewares

Add global or route-level middleware:

```python
from altxria.olympus.routing.middleware import Middleware

class LoggingMiddleware(Middleware):
    def handle_pre(self, request):
        print(f"Received request at {request.path}")
        return None

router.use_global_middleware(LoggingMiddleware())
```

All incoming requests are now logged before being handled.

### Step 4: Group Routes & Enforce HTTPS

```python
from altxria.olympus.routing.decorators import group
from altxria.olympus.routing.middleware import HTTPSMiddleware

@group(prefix="/admin", middlewares=[HTTPSMiddleware(enforce=True)])
class AdminGroup:
    @route("/dashboard", methods=["GET"])
    def dashboard(self, request):
        return {"admin": "This area is protected by HTTPS"}

    @route("/settings", methods=["GET"])
    def settings(self, request):
        return {"settings": "admin config"}
```

---

## 🔍 Project Status

![Issues Closed](https://img.shields.io/github/issues-closed/altxriainc/olympus)
![Bug Issues](https://img.shields.io/github/issues/altxriainc/olympus/bug)
![Enhancement Issues](https://img.shields.io/github/issues/altxriainc/olympus/enhancement)

Olympus is currently in **alpha**. Expect frequent changes and improvements as the framework matures.

---

## 📜 License and Usage

Olympus is licensed under the MIT License, making it free for personal and commercial use. See the [LICENSE](https://github.com/altxriainc/olympus/blob/main/LICENSE) file for more details.

---

## 🤝 Contributors

Developed and maintained by **Altxria Inc.** and the open-source community.

![Contributors](https://contrib.rocks/image?repo=altxriainc/olympus)

[See All Contributors](https://github.com/altxriainc/olympus/graphs/contributors)

---

## ❤️ Support Olympus

If you find Olympus useful, consider sponsoring us to support ongoing development and new features!

[![Sponsor Olympus](https://img.shields.io/badge/Sponsor-Olympus-blue?logo=github-sponsors)](https://github.com/sponsors/altxriainc)

[![ko-fi](https://ko-fi.com/img/githubbutton_sm.svg)](https://ko-fi.com/N4N516SMZ6)

---

**Ready to build your next web application with Olympus?** Jump right in by exploring the [documentation](https://github.com/altxriainc/olympus/wiki) or browsing the code.

            

Raw data

            {
    "_id": null,
    "home_page": null,
    "name": "olympus-framework",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.8",
    "maintainer_email": null,
    "keywords": "web, framework, routing, middleware, http, jinja2",
    "author": null,
    "author_email": "\"Altxria Inc.\" <company@altxria.com>",
    "download_url": "https://files.pythonhosted.org/packages/24/88/0abe09284555763b303af6c805716f8c0ac9da2753cf2f6fa9fc4f221486/olympus_framework-0.1.1.tar.gz",
    "platform": null,
    "description": "\r\n# Olympus\r\n\r\n![Latest Version](https://img.shields.io/pypi/v/olympus-framework)\r\n![Downloads](https://img.shields.io/pypi/dm/olympus-framework)\r\n![Status](https://img.shields.io/badge/status-alpha-orange)\r\n![License: MIT](https://img.shields.io/badge/License-MIT-lightgrey.svg)\r\n\r\n**Olympus** is a Python web framework foundation inspired by the rich routing, middleware, and exception handling systems found in Laravel. It provides a clean, extensible base that you can build upon for full-stack applications, whether you're serving HTML, JSON-based APIs, or file downloads. With Olympus, you can define routes using decorators, group them, apply middlewares globally or at the route level, and handle exceptions elegantly.\r\n\r\n[Click here for the documentation](https://github.com/altxriainc/olympus/wiki)\r\n\r\n---\r\n\r\n## \ud83d\ude80 Key Features\r\n\r\n- **Expressive Routing System**: Define routes via decorators, including route groups, URL parameters, and multiple HTTP methods.\r\n- **Advanced Middleware Support**: Apply middleware globally, per route, or per group. Handle pre- and post-request logic easily.\r\n- **Exception Handling & Custom 404**: Gracefully handle errors and register custom exception handlers, including global 404 responses.\r\n- **HTTPS Enforcement**: Force HTTPS globally or on specific routes/groups with a single middleware.\r\n- **CORS Integration**: Easily add CORS headers to your responses, handle preflight requests.\r\n- **JSON, File, and HTML Responses**: Return JSON APIs, serve files for download, or integrate a templating engine for HTML rendering.\r\n- **Group Prefixes & Middleware Inheritance**: Organize routes into groups that share a prefix, middleware stack, or both.\r\n- **Extensible & Composable**: Olympus is designed as a foundational layer. Plug in your own ORM, templating engine, or validation library.\r\n\r\n---\r\n\r\n## \ud83d\udee0\ufe0f Getting Started\r\n\r\n### Step 1: Install Olympus\r\n\r\nInstall Olympus via pip:\r\n\r\n```bash\r\npip install olympus-framework\r\n```\r\n\r\n*(Ensure you have Python 3.8+ available.)*\r\n\r\n### Step 2: Define Your First Route\r\n\r\nCreate a `main.py`:\r\n\r\n```python\r\nfrom src.server import run_server\r\nfrom src.routing.decorators import route\r\nfrom src.routing.response import Response\r\nfrom src.routing.router import Router\r\nfrom src.exceptions_manager import ExceptionsManager\r\nfrom src.routing.exceptions import HttpNotFoundException\r\n\r\nrouter = Router.get_instance()\r\nexceptions_manager = ExceptionsManager()\r\nrouter.set_exceptions_manager(exceptions_manager)\r\n\r\ndef handle_not_found(exc, request):\r\n    return Response(status=404, body=\"Page not found!\")\r\nexceptions_manager.register_handler(HttpNotFoundException, handle_not_found)\r\n\r\n@route(\"/hello\", methods=[\"GET\"])\r\ndef hello_route(request):\r\n    return {\"message\": \"Hello from Olympus!\"}\r\n\r\nif __name__ == \"__main__\":\r\n    run_server(\"0.0.0.0\", 8000)\r\n```\r\n\r\nNow, open [http://localhost:8000/hello](http://localhost:8000/hello) in your browser.\r\n\r\n### Step 3: Use Middlewares\r\n\r\nAdd global or route-level middleware:\r\n\r\n```python\r\nfrom altxria.olympus.routing.middleware import Middleware\r\n\r\nclass LoggingMiddleware(Middleware):\r\n    def handle_pre(self, request):\r\n        print(f\"Received request at {request.path}\")\r\n        return None\r\n\r\nrouter.use_global_middleware(LoggingMiddleware())\r\n```\r\n\r\nAll incoming requests are now logged before being handled.\r\n\r\n### Step 4: Group Routes & Enforce HTTPS\r\n\r\n```python\r\nfrom altxria.olympus.routing.decorators import group\r\nfrom altxria.olympus.routing.middleware import HTTPSMiddleware\r\n\r\n@group(prefix=\"/admin\", middlewares=[HTTPSMiddleware(enforce=True)])\r\nclass AdminGroup:\r\n    @route(\"/dashboard\", methods=[\"GET\"])\r\n    def dashboard(self, request):\r\n        return {\"admin\": \"This area is protected by HTTPS\"}\r\n\r\n    @route(\"/settings\", methods=[\"GET\"])\r\n    def settings(self, request):\r\n        return {\"settings\": \"admin config\"}\r\n```\r\n\r\n---\r\n\r\n## \ud83d\udd0d Project Status\r\n\r\n![Issues Closed](https://img.shields.io/github/issues-closed/altxriainc/olympus)\r\n![Bug Issues](https://img.shields.io/github/issues/altxriainc/olympus/bug)\r\n![Enhancement Issues](https://img.shields.io/github/issues/altxriainc/olympus/enhancement)\r\n\r\nOlympus is currently in **alpha**. Expect frequent changes and improvements as the framework matures.\r\n\r\n---\r\n\r\n## \ud83d\udcdc License and Usage\r\n\r\nOlympus is licensed under the MIT License, making it free for personal and commercial use. See the [LICENSE](https://github.com/altxriainc/olympus/blob/main/LICENSE) file for more details.\r\n\r\n---\r\n\r\n## \ud83e\udd1d Contributors\r\n\r\nDeveloped and maintained by **Altxria Inc.** and the open-source community.\r\n\r\n![Contributors](https://contrib.rocks/image?repo=altxriainc/olympus)\r\n\r\n[See All Contributors](https://github.com/altxriainc/olympus/graphs/contributors)\r\n\r\n---\r\n\r\n## \u2764\ufe0f Support Olympus\r\n\r\nIf you find Olympus useful, consider sponsoring us to support ongoing development and new features!\r\n\r\n[![Sponsor Olympus](https://img.shields.io/badge/Sponsor-Olympus-blue?logo=github-sponsors)](https://github.com/sponsors/altxriainc)\r\n\r\n[![ko-fi](https://ko-fi.com/img/githubbutton_sm.svg)](https://ko-fi.com/N4N516SMZ6)\r\n\r\n---\r\n\r\n**Ready to build your next web application with Olympus?** Jump right in by exploring the [documentation](https://github.com/altxriainc/olympus/wiki) or browsing the code.\r\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "A Python web framework foundation inspired by Laravel's routing, middleware, and exception handling.",
    "version": "0.1.1",
    "project_urls": {
        "Bug Tracker": "https://github.com/altxriainc/olympus/issues",
        "Documentation": "https://github.com/altxriainc/olympus/wiki",
        "Source Code": "https://github.com/altxriainc/olympus"
    },
    "split_keywords": [
        "web",
        " framework",
        " routing",
        " middleware",
        " http",
        " jinja2"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "5aeb958b2c7141aec128de439a1f68755b0cec41e62d866696659f04f5a510fd",
                "md5": "1a6af1d740b998d06c46732a8fb30784",
                "sha256": "ac6df5a3489f64d675eebc5f5feabfd2d367fa28707a903ac23d3753f883e21a"
            },
            "downloads": -1,
            "filename": "olympus_framework-0.1.1-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "1a6af1d740b998d06c46732a8fb30784",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.8",
            "size": 14024,
            "upload_time": "2024-12-19T20:09:47",
            "upload_time_iso_8601": "2024-12-19T20:09:47.527157Z",
            "url": "https://files.pythonhosted.org/packages/5a/eb/958b2c7141aec128de439a1f68755b0cec41e62d866696659f04f5a510fd/olympus_framework-0.1.1-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "24880abe09284555763b303af6c805716f8c0ac9da2753cf2f6fa9fc4f221486",
                "md5": "c49d51a19db0b6aea992c1f5415b0f06",
                "sha256": "6ab7716ff84e7f5f417f662161c31ec6e7cc263e1560661941947f558b52f10f"
            },
            "downloads": -1,
            "filename": "olympus_framework-0.1.1.tar.gz",
            "has_sig": false,
            "md5_digest": "c49d51a19db0b6aea992c1f5415b0f06",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.8",
            "size": 12728,
            "upload_time": "2024-12-19T20:09:50",
            "upload_time_iso_8601": "2024-12-19T20:09:50.181939Z",
            "url": "https://files.pythonhosted.org/packages/24/88/0abe09284555763b303af6c805716f8c0ac9da2753cf2f6fa9fc4f221486/olympus_framework-0.1.1.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-12-19 20:09:50",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "altxriainc",
    "github_project": "olympus",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "lcname": "olympus-framework"
}
        
Elapsed time: 0.37268s