Skip to main content

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

  1. Create a static directory and add an index.html file:

    <!-- static/index.html -->
    <!DOCTYPE html>
    <html>
    <head>
            <title>Static File</title>
    </head>
    <body>
            <h1>Hello from a static file!</h1>
    </body>
    </html>
    
  2. Update main.py to 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()
    
  3. Visit http://localhost:8080/static/index.html to 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 → Returns 404 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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

endly-0.1.1.tar.gz (8.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

endly-0.1.1-py3-none-any.whl (8.5 kB view details)

Uploaded Python 3

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

Hashes for endly-0.1.1.tar.gz
Algorithm Hash digest
SHA256 be897fe2619fccd79b398672ca92c8c7cfb493147f1c7707e83a57183667a568
MD5 2708b83eb94d01b82d826b3b338ad686
BLAKE2b-256 383ab5bb310227123aa7b82a1080d88379907a13e85be509cf6ba033cac67b5d

See more details on using hashes here.

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

Hashes for endly-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 ad7a3b8b5dedb8d2fd4b9d2b2037418e83c50696b61031d8af0994c7a5433591
MD5 c777a9f5c508594646b3ab2858d17c34
BLAKE2b-256 8b9c007bbd6176db5856b630002f7ff51d26c05f3bf478db73d0fe179228a8a2

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page