#Nebula - A lightweight Python backend framework with middleware and routing.

109 messages · Page 1 of 1 (latest)

neat vault
#

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

GitHub

Lightweight Python HTTP server with decorator-based routing. - VxidDev/Nebula

sullen quail
#

thats cool, i think it will be a very good alternative to flask

sullen quail
neat vault
neat vault
sullen quail
sullen quail
neat vault
#

im already almost done with jsonify(dictionary: dict, status: int = 200) and after that ill start making POST request

#

after adding post request, ill release it on pypi

sullen quail
#

Try to make for user possible to return just dict, not result of jsonify

neat vault
#

Nebula - A lightweight Python backend framework with middleware and routing.

neat vault
neat vault
#

Added post request support :D

neat vault
sullen quail
neat vault
#

dayumm! sure!

#

itll take a while though because of all updates i had added in meanwhile

sullen quail
neat vault
neat vault
neat vault
#

Updated error handling, now you can handle a http code from 400 up to 599 using:

@app.error_handler(http_code: int)
def handle_error():
  return Response("Some error happened!", http_code)
neat vault
#

Migrated Nebula to werkzeug. still alot of work is left to make sure its stable.

neat vault
neat vault
#

Added render_template and render_template_string :]

neat vault
jaunty hatch
neat vault
#

Sounds really helpful!

jaunty hatch
#

You should also upgrade type annotations. typing.List, typing.Callable and some other things from typing are deprecated.

#

Since you're already requiring Python 3.10+

latent cosmosBOT
#

nebula/server.py lines 68 to 70

if not isinstance(response, WerkzeugResponse):
    # If the view function returns a string, wrap it in a Response object
    response = WerkzeugResponse(str(response), 200)```
neat vault
#

I think i should change it to something like:

# if the view function returns an object which is not Response, wrap it in Response object

#

Or add an additional isinstance check for if string

jaunty hatch
#

I would avoid comments like this that explain what the code does (when it's already clear)

neat vault
#

new QoL life update:
https://github.com/VxidDev/Nebula/releases/tag/1.2.3

this release adds Nebula.init_all(...) that initializes everything by itself. This is supposed to be used to initialize everything instead of manually running all initializers

GitHub

This release adds a QoL features and a slight API change.
New Features

Nebula.init_all(...) - run all initializers from utils.initializers:

init_static_serving(app, current_request , endpoint: st...

neat vault
neat vault
neat vault
neat vault
zealous citrus
#

I suggest add async support.

#

support msgspec dataclass for DTO

#

such as Litestar framework (a python fast web api server)

sullen quail
sullen quail
zealous citrus
#

so ga

sullen quail
#

just added websockets

#

deploying update

zealous citrus
#

a real async file lib for python , windows IOCP based

sullen quail
zealous citrus
neat vault
#

Nebula is slowly becoming deprecated after the appearance of Project Nebula, which is basically the old Nebula but with better core based on ASGI instead of WSGI. So I recommend switching to better Nebula co-founded by me :] It still lacks some features, but in future they'll get re-added!

GitHub

Python micro framework for backend development. Contribute to amogus-gggy/Project-Nebula development by creating an account on GitHub.

zealous citrus
neat vault
#

some API changes, yet im pretty sure they will be normalized in future!

zealous citrus
#

it's looks like fastapi:)

zealous citrus
sullen quail
neat vault
sullen quail
sullen quail
zealous citrus
sullen quail
#

So, everyone pls go to new theme

#

We need traffic there

zealous citrus
# sullen quail Our framework is cross platform. Unless you create something that works on any p...

You're absolutely right — aiowinfile is Windows-only, and that's a clear limitation for cross-platform frameworks.

However, it solves a problem that's been overlooked for years: Python never had a truly high-performance async file I/O solution on Windows.
For users who are stuck on Windows (enterprise internal systems, healthcare, industrial control, etc.), aiowinfile delivers 2-3x throughput with much lower latency compared to thread-pool based solutions like aiofiles.

Cross-platform is ideal, but the reality is many workloads run on Windows and deserve better performance. That's what this library is for.

That said, if Linux io_uring matures in the Python ecosystem, I'd love to add cross-platform support. Until then, focusing on Windows seems like a reasonable trade-off.

neat vault
#

most HTTP servers are on linux

zealous citrus
#

: )

zealous citrus
neat vault
#

for now, nebula focuses on performance, ease of use and supporting cross-platform. Adding another dependency will make framework heavier and not the cross-platform

#

therefore, adding aiowinfile doesn't seem rational for now

neat vault
#

wdym by that?

zealous citrus
neat vault
#

oh, oki

zealous citrus
neat vault
sullen quail
#

Global update of new Project Nebula: 1.0.2
Changelog:
Addded new response types(PlainTextResponse, StreamingResponse, FileResponse, RedirectResponse)
Added app.mount(for something like static directory)
Added app.run(still using uvicorn)
A lot of internal optimizations(most of the time we are outperforming fastapi, or same performance as fastapi)

⛓️‍💥 Links:
https://pypi.org/project/project-nebula/
https://github.com/amogus-gggy/Project-Nebula

@neat vault

GitHub

Python micro framework for backend development. Contribute to amogus-gggy/Project-Nebula development by creating an account on GitHub.

zealous citrus
zealous citrus
sullen quail
neat vault
neat vault
neat vault
neat vault
#

Performed a really basic benchmark between FastAPI and Nebula, code for both is really simple:

FastAPI:

from fastapi import FastAPI
from fastapi.responses import HTMLResponse
import uvicorn

app = FastAPI()

@app.get("/", response_class=HTMLResponse)
async def root():
    return "<h1>Welcome to FastAPI!</h1>"

if __name__ == "__main__":
    uvicorn.run(app, host="127.0.0.1", port=5000)

Nebula:

from nebula import Nebula , run_dev
from nebula.utils import htmlify

app = Nebula(__file__, "localhost", 8000)

@app.route("/")
async def root(request) -> None:
    return htmlify("<h1>Welcome to Nebula!</h1>")

if __name__ == "__main__":
    run_dev(app)

ran the both using same command:

uvicorn <name>:app --workers 1 --loop uvloop --http httptools --port 5000

and benchmarked using:

wrk -t2 -c50 -d5s http://127.0.0.1:5000/ # warm-up
wrk -t4 -c100 -d30s http://127.0.0.1:5000/ # x3

result:

FastAPI average ≈ 4667 RPS
Nebula ≈ 7683 RPS

plain nexus
#

I'm developing smth similar to this apparently

#

btw isnt bottle.py alrdy a good altenative to flask

#

not that I'm trying to discourage or anything

neat vault
neat vault
neat vault
#

New Nebula update!

This update introduces changes to route signatures and easier request handling :]

Release Notes

GitHub

Nebula 3.1.1 - Release Notes
What’s New
⚠️ Behavior change: The request object is no longer always injected automatically into route handlers.
Request is now only injected when one of the followin...

neat vault
#

Nebula update... once again! cri

This update introduces automatic response class type detection :]

Release Notes

GitHub

Nebula 3.1.2 - Release Notes
What’s New
⚠️ Behavior change: Automatic response wrapping has been introduced.
Route return values are now automatically converted into the appropriate response type, ...

neat vault
#

Nebula update :]

This update introduces RouteGroup alongside updating response class type detection :)

Release Notes

GitHub

Nebula 3.1.4 - Release Notes
What’s New
⚠️ Behavior change: Automatic response wrapping has been updated.
Added RouteGroup, enabling cleaner and more organized route definitions, and laying the fou...

neat vault
#

Nebula update!! :D

This update enhances RouteGroup by allowing private middleware alongside refactoring middleware itself for "starlette-style" (classes)

Release Notes

GitHub

Nebula 3.2.0 - Release Notes
What’s New
⚠️ Middleware System Update (Major)
Nebula now supports composable middleware at two levels:

Global ASGI Middleware - wraps the entire application
Route-lev...

neat vault
#

New nebula update!

  • Added nebula.server.request
  • Implemented dynamic argument injection for error handlers

Release Notes

GitHub

Nebula 3.3.0 - Release Notes
What’s New
⚠️ Error Dispatcher & Injection System (Major)
Nebula introduces a flexible injection system for error handlers along with a fully redesigned error dispa...

zealous citrus
#

I supports it cross platform

#

use io_uring on linux, IOCP on win, Thread Pool on mac os

sullen quail
zealous citrus
#

benchmark