Endly
Endly is a lightweight Python web framework for building fast and scalable backend applications. It provides a simple and intuitive API for defining routes, handling requests, and serving static files.
Table of Contents
Features
- Routing: Define routes with dynamic parameters.
- Static File Serving: Serve static files from a specified directory.
- Middleware: Add pre-processing and post-processing middleware.
- JSON Support: Automatically serialize Python dictionaries to JSON responses.
- Error Handling: Custom error handlers for 404 and 500 errors.
- Concurrency: Handle multiple requests concurrently using threading.
- Logging: Built-in logging for debugging and monitoring.
Installation
You can install Endly using pip:
pip install endly
For development installation:
# Clone the repository
git clone https://github.com/yourusername/endly.git
cd endly
# Install in development mode
pip install -e .
To verify installation:
import endly
Usage
Basic Example
from endly import App, route
# Create the app
app = App(__name__, host="0.0.0.0", port=8080)
# Define routes
@app.group('/api')
class UserRoutes:
@route('/home')
def home():
return "Hello, World!"
@route('/user/<name>')
def user(name):
return {"message": f"Hello, {name}!"}
# Run the server
app.run()
Serving Static Files
-
Create a
staticdirectory and add anindex.htmlfile:<!-- static/index.html --> <!DOCTYPE html> <html> <head> <title>Static File</title> </head> <body> <h1>Hello from a static file!</h1> </body> </html>
-
Update
main.pyto serve static files:from endly import App, route # Create the app with static file support app = App(__name__, host="0.0.0.0", port=8080, static_dir="static") # Define routes @app.group('/api') class UserRoutes: @route('/home') def home(): return "Welcome to the Home Page!" # Run the server app.run()
-
Visit
http://localhost:8080/static/index.htmlto view the static file.
Middleware
Add middleware for pre-processing and post-processing requests:
from endly import App, route
# Create the app
app = App(__name__, host="0.0.0.0", port=8080)
# Define routes
@app.group('/api')
class UserRoutes:
@route('/home')
def home():
return "Welcome to the Home Page!"
# Run the server
app.run()
Middleware logs:
Pre-processing request: /api/home
Post-processing response: Response
Error Handling
Custom error handlers for 404 and 500 errors:
from endly import App, route
# Create the app
app = App(__name__, host="0.0.0.0", port=8080)
# Define routes
@app.group('/api')
class UserRoutes:
@route('/home')
def home():
return "Welcome to the Home Page!"
# Run the server
app.run()
Test error handling:
- Visit
http://localhost:8080/invalid→ Returns404 Not Found.
Contributing
Contributions are welcome! Please open an issue or submit a pull request.
License
This project is licensed under the MIT License. See the LICENSE file for details.
Project Structure
Here's the recommended project structure:
endly/
│
├── endly/
│ ├── __init__.py
│ ├── app.py
│ ├── router.py
│ ├── middleware.py
│ ├── static.py
│ ├── errors.py
│ └── logging.py
│
├── main.py
├── README.md
├── LICENSE
Future Updates
Here's what's coming in future releases:
- Authentication middleware and JWT support
- Database integration (SQLAlchemy, MongoDB)
- WebSocket support for real-time applications
- Rate limiting and request throttling
- API documentation generator
- GraphQL integration
- Docker containerization support
- Testing utilities and fixtures
- Performance optimization tools
- CLI tool for project scaffolding
Metadata
Release files for endly 0.1.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 | |
|---|---|---|---|
| endly-0.1.1.tar.gz | 8.2 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| endly-0.1.1-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 16.7 kB
Release files / endly-0.1.1.tar.gz
| Download URL | endly-0.1.1.tar.gz |
|---|---|
| Size | 8.2 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
be897fe2619fccd79b398672ca92c8c7cfb493147f1c7707e83a57183667a568
|
|
BLAKE2b-256 checksum How to use checksums |
383ab5bb310227123aa7b82a1080d88379907a13e85be509cf6ba033cac67b5d
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.9.21
|
Release files / endly-0.1.1-py3-none-any.whl
| Download URL | endly-0.1.1-py3-none-any.whl |
|---|---|
| Size | 8.5 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
ad7a3b8b5dedb8d2fd4b9d2b2037418e83c50696b61031d8af0994c7a5433591
|
|
BLAKE2b-256 checksum How to use checksums |
8b9c007bbd6176db5856b630002f7ff51d26c05f3bf478db73d0fe179228a8a2
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.9.21
|