Skip to main content

Fast & Friendly, Web Framework For Building Async APIs

Project description

PyPI PyVersion codecov Downloads license

Panther

Is A Fast & Friendly Web Framework For Building Async APIs With Python 3.10+

logo

📚 Full Documentation: PantherPy.GitHub.io


Why Use Panther ?

  • Include Simple File-Base Database (PantherDB)
  • Built-in Document-oriented Databases ODM (MongoDB, PantherDB)
  • Built-in Websocket Support
  • Built-in API Caching System (In Memory, Redis)
  • Built-in Authentication Classes
  • Built-in Permission Classes
  • Built-in Visual API Monitoring (In Terminal)
  • Support Custom Background Tasks
  • Support Custom Middlewares
  • Support Custom Throttling
  • Support Function-Base and Class-Base APIs
  • It's One Of The Fastest Python Framework (Benchmark)

Supported by

jetbrains

Installation

$ pip install panther

Usage

  • Create Project

    $ panther create
    
  • Run Project

    $ panther run --reload
    

    * Panther uses Uvicorn as ASGI (Asynchronous Server Gateway Interface) but you can run the project with Granian, daphne or any ASGI server

  • Monitoring Requests

    $ panther monitor 
    
  • Python Shell

    $ panther shell
    

API Example

  • Create main.py

    from datetime import datetime, timedelta
    
    from panther import status, Panther
    from panther.app import GenericAPI
    from panther.response import Response
    
    
    class FirstAPI(GenericAPI):
        # Cache Response For 10 Seconds
        cache = True
        cache_exp_time = timedelta(seconds=10)
        
        def get(self):
            date_time = datetime.now().isoformat()
            data = {'detail': f'Hello World | {date_time}'}
            return Response(data=data, status_code=status.HTTP_202_ACCEPTED)
    
    
    url_routing = {'': FirstAPI}
    app = Panther(__name__, configs=__name__, urls=url_routing)
    
  • Run the project:

    • $ panther run --reload
  • Checkout the http://127.0.0.1:8000/

WebSocket Echo Example

  • Create main.py

    from panther import Panther
    from panther.app import GenericAPI
    from panther.response import HTMLResponse
    from panther.websocket import GenericWebsocket
    
    
    class FirstWebsocket(GenericWebsocket):
        async def connect(self, **kwargs):
            await self.accept()
    
        async def receive(self, data: str | bytes):
            await self.send(data)
    
    
    class MainPage(GenericAPI):
        def get(self):
            template = """
            <input type="text" id="messageInput">
            <button id="sendButton">Send Message</button>
            <ul id="messages"></ul>
            <script>
                var socket = new WebSocket('ws://127.0.0.1:8000/ws');
                socket.addEventListener('message', function (event) {
                    var li = document.createElement('li');
                    document.getElementById('messages').appendChild(li).textContent = 'Server: ' + event.data;
                });
                function sendMessage() {
                    socket.send(document.getElementById('messageInput').value);
                }
                document.getElementById('sendButton').addEventListener('click', sendMessage);
            </script>
            """
            return HTMLResponse(template)
    
    url_routing = {
        '': MainPage,
        'ws': FirstWebsocket,
    }
    app = Panther(__name__, configs=__name__, urls=url_routing)
    
  • Run the project:

    • $ panther run --reload
  • Go to http://127.0.0.1:8000/ and work with your websocket

Next Step: First CRUD


How Panther Works!

diagram


Roadmap

roadmap


If you find this project 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-4.3.5.tar.gz (75.7 kB view details)

Uploaded Source

Built Distribution

panther-4.3.5-py3-none-any.whl (67.7 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: panther-4.3.5.tar.gz
  • Upload date:
  • Size: 75.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.9.20

File hashes

Hashes for panther-4.3.5.tar.gz
Algorithm Hash digest
SHA256 a4ffe346eeee275ece3811b8fceac12502cfb13d694dd95ab2cfa766e6b313f3
MD5 8dc40d0bdb98b286b15e0ce2f889f448
BLAKE2b-256 ad1d13303cbb94eb5426b7412ead404d84bfcb5e35e6c4160d37b7fa4d9ebf93

See more details on using hashes here.

File details

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

File metadata

  • Download URL: panther-4.3.5-py3-none-any.whl
  • Upload date:
  • Size: 67.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.9.20

File hashes

Hashes for panther-4.3.5-py3-none-any.whl
Algorithm Hash digest
SHA256 a793d45315f6f410706c2e465da5764fd525eb039eeeffad9bd1a44f4a717cc3
MD5 ee5764eb5ce3a5e5f37cafd2a419ae2c
BLAKE2b-256 89f28a40f0112f6b64bf993c0f769599f4410ada19a157dfbd010fde78726d76

See more details on using hashes here.

Supported by

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