Skip to main content

Fast & Friendly, Web Framework For Building Async APIs

Project description

PyPI PyVersion codecov Downloads license

Panther Logo

Panther

A Fast & Friendly Web Framework for Building Async APIs with Python 3.10+

📚 Documentation


🐾 Why Choose Panther?

Panther is designed to be fast, simple, and powerful. Here's what makes it special:

  • One of the fastest Python frameworks available (Benchmark)
  • File-based database (PantherDB) - No external database setup required
  • Document-oriented ODM - Supports MongoDB & PantherDB with familiar syntax
  • API caching system - In-memory and Redis support
  • OpenAPI - Auto-generated API documentation with multiple UI options
  • WebSocket support - Real-time communication out of the box
  • Authentication & Permissions - Built-in security features
  • Background tasks - Handle long-running operations
  • Middleware & Throttling - Extensible and configurable

Quick Start

Installation

pip install panther
  • Create a main.py file with one of the examples below.

Your First API

Here's a simple REST API endpoint that returns a "Hello World" message:

from datetime import datetime, timedelta
from panther import status, Panther
from panther.app import GenericAPI
from panther.openapi.urls import url_routing as openapi_url_routing
from panther.response import Response

class HelloAPI(GenericAPI):
    # Cache responses for 10 seconds
    cache = timedelta(seconds=10)
    
    def get(self):
        current_time = datetime.now().isoformat()
        return Response(
            data={'message': f'Hello from Panther! 🐾 | {current_time}'},
            status_code=status.HTTP_200_OK
        )

# URL routing configuration
url_routing = {
    '/': HelloAPI,
    'docs/': openapi_url_routing,  # Auto-generated API docs
}

# Create your Panther app
app = Panther(__name__, configs=__name__, urls=url_routing)

WebSocket Echo Server

Here's a simple WebSocket echo server that sends back any message it receives:

from panther import Panther
from panther.app import GenericAPI
from panther.response import HTMLResponse
from panther.websocket import GenericWebsocket

class EchoWebsocket(GenericWebsocket):
    async def connect(self, **kwargs):
        await self.accept()
        await self.send("Connected to Panther WebSocket!")
    
    async def receive(self, data: str | bytes):
        # Echo back the received message
        await self.send(f"Echo: {data}")

class WebSocketPage(GenericAPI):
    def get(self):
        template = """
        <h2>🐾 Panther WebSocket Echo Server</h2>
        <input id="msg"><button onclick="s.send(msg.value)">Send</button>
        <ul id="log"></ul>
        <script>
            const s = new WebSocket('ws://127.0.0.1:8000/ws');
            s.onmessage = e => log.innerHTML += `<li><- ${msg.value}</li><li>-> ${e.data}</li>`;
        </script>
        """
        return HTMLResponse(template)

url_routing = {
    '': WebSocketPage,
    'ws': EchoWebsocket,
}
app = Panther(__name__, configs=__name__, urls=url_routing)

Run Your Application

  1. Start the development server

    $ panther run main:app
    
  2. Test your application


For LLMs and Coding Agents

Start with:

These files are kept focused on current Panther APIs and copyable examples.


🙏 Acknowledgments

Supported by

JetBrains

⭐️ If you find Panther useful, please give it a star!

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

panther-5.4.0.tar.gz (138.8 kB view details)

Uploaded Source

Built Distribution

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

panther-5.4.0-py3-none-any.whl (112.3 kB view details)

Uploaded Python 3

File details

Details for the file panther-5.4.0.tar.gz.

File metadata

  • Download URL: panther-5.4.0.tar.gz
  • Upload date:
  • Size: 138.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for panther-5.4.0.tar.gz
Algorithm Hash digest
SHA256 1247149e82086f9d806981d39b917bc91b0d7c1e41a97e5b59bf6c75955cbe5b
MD5 f56cac82ef204b8916f608cc58307397
BLAKE2b-256 4ffb9cd7a3c9884287d0f19dd2c39cb789404a3751684920f44df740d36cba42

See more details on using hashes here.

File details

Details for the file panther-5.4.0-py3-none-any.whl.

File metadata

  • Download URL: panther-5.4.0-py3-none-any.whl
  • Upload date:
  • Size: 112.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for panther-5.4.0-py3-none-any.whl
Algorithm Hash digest
SHA256 0d66e823b940d8f887ff261ae63d66e9a8fbd7ec9664d2f7339ea15ee3a11a40
MD5 3f92846c8dce2c982d49e609a7a474c5
BLAKE2b-256 534ae5306e53c7a2a458341476f4eb9153ba77bbf90a9712b72d1b62df11ce52

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