Skip to main content

A Python web framework foundation inspired by Laravel's routing, middleware, and exception handling.

Project description

Olympus

Latest Version Downloads Status License: MIT

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


🚀 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:

pip install olympus-framework

(Ensure you have Python 3.8+ available.)

Step 2: Define Your First Route

Create a main.py:

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 in your browser.

Step 3: Use Middlewares

Add global or route-level middleware:

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

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 Bug Issues Enhancement Issues

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 file for more details.


🤝 Contributors

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

Contributors

See All Contributors


❤️ Support Olympus

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

Sponsor Olympus

ko-fi


Ready to build your next web application with Olympus? Jump right in by exploring the documentation or browsing the code.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

olympus_framework-0.1.1.tar.gz (12.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

olympus_framework-0.1.1-py3-none-any.whl (14.0 kB view details)

Uploaded Python 3

File details

Details for the file olympus_framework-0.1.1.tar.gz.

File metadata

  • Download URL: olympus_framework-0.1.1.tar.gz
  • Upload date:
  • Size: 12.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.0.1 CPython/3.12.8

File hashes

Hashes for olympus_framework-0.1.1.tar.gz
Algorithm Hash digest
SHA256 6ab7716ff84e7f5f417f662161c31ec6e7cc263e1560661941947f558b52f10f
MD5 c49d51a19db0b6aea992c1f5415b0f06
BLAKE2b-256 24880abe09284555763b303af6c805716f8c0ac9da2753cf2f6fa9fc4f221486

See more details on using hashes here.

File details

Details for the file olympus_framework-0.1.1-py3-none-any.whl.

File metadata

File hashes

Hashes for olympus_framework-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 ac6df5a3489f64d675eebc5f5feabfd2d367fa28707a903ac23d3753f883e21a
MD5 1a6af1d740b998d06c46732a8fb30784
BLAKE2b-256 5aeb958b2c7141aec128de439a1f68755b0cec41e62d866696659f04f5a510fd

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page