A lightweight Python web framework for building fast and scalable backend applications
Project description
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
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file endly-0.1.1.tar.gz.
File metadata
- Download URL: endly-0.1.1.tar.gz
- Upload date:
- Size: 8.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.9.21
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
be897fe2619fccd79b398672ca92c8c7cfb493147f1c7707e83a57183667a568
|
|
| MD5 |
2708b83eb94d01b82d826b3b338ad686
|
|
| BLAKE2b-256 |
383ab5bb310227123aa7b82a1080d88379907a13e85be509cf6ba033cac67b5d
|
File details
Details for the file endly-0.1.1-py3-none-any.whl.
File metadata
- Download URL: endly-0.1.1-py3-none-any.whl
- Upload date:
- Size: 8.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.9.21
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ad7a3b8b5dedb8d2fd4b9d2b2037418e83c50696b61031d8af0994c7a5433591
|
|
| MD5 |
c777a9f5c508594646b3ab2858d17c34
|
|
| BLAKE2b-256 |
8b9c007bbd6176db5856b630002f7ff51d26c05f3bf478db73d0fe179228a8a2
|