Nebula is a lightweight and easy-to-use HTTP server for Python, built on top of the standard http.server module. It allows you to create web applications quickly with simple, decorator-based routing.
Features
- Lightweight: Built on Python's standard library with no external dependencies.
- Decorator-based Routing: Define your routes with simple and intuitive decorators.
- Template Loading: Easily load and serve HTML templates from a designated directory.
- Easy to Use: Get a server up and running in just a few lines of code.
Example
from nebula import Nebula , Response
from pathlib import Path
app = Nebula("localhost", 8000, True)
app.templates_dir = Path(__file__).resolve().parent / "templates"
@app.before_request
def func(request):
print(f"received request on {request.route.path} with method {request.method}...")
@app.after_request
def func(request):
print(f"successfully handled request on {request.route.path} with method {request.method}...")
@app.internal_error_handler
def internal_error():
return Response('<h1 style="font-size: 100px;">something doesnt working.</h1>', 500)
@app.route("/")
def main():
return Response(app.load_template("test.html"), 200)
app.run()
Nebula is in early development stages so alot of things arent added yet.
Repository: Nebula
