Nebula
Nebula is a lightweight ASGI-based Python web framework that provides simple, decorator-based routing and middleware support for building fast, asynchronous web applications.
Features
- Decorator-based Routing: Define your routes with simple and intuitive decorators.
- Asynchronous Support: Full
async/awaitsupport for handling requests and events. - Session Management: Secure session handling using HMAC-signed cookies.
- WebSocket Support: Integrated
python-socketiofor real-time communication. - Template Loading: Easily load and serve HTML templates from a designated directory using Jinja2.
- Statics Loading: Easily load and serve static files from a designated directory.
- Middleware Support: Chain middleware for request/response processing, both globally and per-route/group.
- Flexible Error Handling: Define custom handlers for HTTP errors.
- Easy to Use: Get a server up and running in just a few lines of code.
Installation
Install Nebula from PyPI:
pip install nebula-core
or clone and install from GitHub:
git clone https://github.com/VxidDev/nebula.git
cd nebula
pip install .
Project Structure
The Nebula project follows a standard Python project structure:
.: Root directory containing configuration files (.gitignore,pyproject.toml,README.md,LICENSE).examples/: Example applications demonstrating various Nebula features.nebula/: The core library code.cache.py: Defines cache related class and decorator (@cached).middleware.py: Defines middleware classes (BaseMiddleware,Middleware).routing.py: Handles route definitions (Route,RouteGroup) and path matching.server.py: The main ASGI application, request handling, and middleware composition logic.request.py: Defines theRequestobject and context.response.py: Defines variousResponseclasses (PlainText, HTML, JSON, Redirect).session.py: Implements session management (SecureCookieSessionManager).types.py: Contains constants like available HTTP methods and default error messages.exceptions.py: Defines custom exceptions used by the framework.utils/: Utility functions for templating, static file serving, etc.
tests/: Contains unit and integration tests for the framework.
Usage Examples
Basic Routing
A simple web server with a root endpoint:
from nebula import Nebula
app = Nebula()
@app.get("/")
async def root():
return "<h1>Welcome to Nebula!</h1>"
if __name__ == "__main__":
app.run()
Production Deployment with Multiple Workers
For production use, deploy with multiple workers for better performance and reliability:
from nebula import Nebula, run_prod
app = Nebula()
@app.get("/")
async def root():
return "<h1>Welcome to Nebula!</h1>"
if __name__ == "__main__":
# Import string is auto-detected automatically!
run_prod(app, workers=4, host="0.0.0.0", port=8000)
The run_prod() function automatically detects the import string, so you don't need to manually configure it. Just specify the number of workers and Nebula will handle the rest!
Contributing
Contributions are welcome!
- Bug Reports: Please report bugs in the GitHub Issues section.
- Feature Requests: Feel free to open an issue to discuss new features.
- Pull Requests: Fork the repository, create a new branch for your feature or bugfix, and submit a pull request. Please ensure your code follows the project's coding style and includes tests.
License
This project is licensed under the MIT License - see the LICENSE file for details.
Metadata
Release files for nebula-core 3.4.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| nebula_core-3.4.1.tar.gz | 27.1 kB | Without provenance | Details for nebula_core-3.4.1.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| nebula_core-3.4.1-py3-none-any.whl | Python 3 | none | any | Details for nebula_core-3.4.1-py3-none-any.whl |
Total release size: 50.1 kB
Release files / nebula_core-3.4.1.tar.gz
| Download URL | nebula_core-3.4.1.tar.gz |
|---|---|
| Size | 27.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
558bca0e18caa48f6267e0d1ec689c42ff75490ec8e48975e7bccf5a406cfac0
|
|
BLAKE2b-256 checksum How to use checksums |
7a45b159af9002dd26c5d77c0a4fb7d3b5d48dcc689770c66d72cc9fcc0edb7a
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.10.13
|
Release files / nebula_core-3.4.1-py3-none-any.whl
| Download URL | nebula_core-3.4.1-py3-none-any.whl |
|---|---|
| Size | 23.0 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
7e2634295c4444ee6725e09b7db50d432d4bf8ecff2e868e32a90df935ce37ed
|
|
BLAKE2b-256 checksum How to use checksums |
3500e166bce62f72fb98a9156530713f2b2d117ffeec4d51466753145542a313
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.10.13
|
Security for nebula-core 3.4.1
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.