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
- 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.
Install Olympus via pip:
pip install olympus-framework
(Ensure you have Python 3.8+ available.)
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.
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.
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"}
Olympus is currently in alpha. Expect frequent changes and improvements as the framework matures.
Olympus is licensed under the MIT License, making it free for personal and commercial use. See the LICENSE file for more details.
Developed and maintained by Altxria Inc. and the open-source community.
If you find Olympus useful, consider sponsoring us to support ongoing development and new features!
Ready to build your next web application with Olympus? Jump right in by exploring the documentation or browsing the code.