Skip to main content

Fast & Friendly, Web Framework For Building Async APIs

Project description

Panther

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

logo

logo Supported by JetBrain

Full Documentation: https://pantherpy.github.io

PyPI: https://pypi.org/project/panther/


Why Use Panther ?

  • Document-oriented Databases ODM (PantherDB, MongoDB)
  • Visual API Monitoring (In Terminal)
  • Cache APIs (In Memory, In Redis)
  • Built-in Authentication Classes (Customizable)
  • Built-in Permission Classes (Customizable)
  • Handle Custom Middlewares
  • Handle Custom Throttling

Installation

  • Create a Virtual Environment
    $ python3 -m venv .venv
  • Active The Environment * Linux & Mac
    $ source .venv/bin/activate
    * Windows
    $ .\.venv\Scripts\activate
  • Install Panther * Normal
    $ pip install panther
    * Include MongoDB Requirements
    $ pip install panther[full]

Usage

  • Create Project

    $ panther create <project_name> <directory>
    
  • Run Project

    Panther uses Uvicorn as ASGI (Asynchronous Server Gateway Interface)

    $ panther run 
    
  • Monitoring Requests

    $ panther monitor 
    
  • Python Shell

    Panther Uses bpython for shell

    $ panther shell 
    

Example

  • You can create project with

    $ panther create myproject
    
  • or create it yourself:

    core/configs.py:

    URLs = 'core/urls.py'
    

    core/urls.py:

    from app.urls import urls as app_urls
    
    urls = {
        '/': app_urls,
    }
    

    app/urls.py:

    from app.apis import hello_world, info
    
    urls = {
        '': hello_world,
        'info/': info,
    }
    

    app/apis.py:

    from datetime import datetime, timedelta
    
    from panther.app import API
    from panther.configs import config
    from panther import version, status
    from panther.request import Request
    from panther.response import Response
    from panther.throttling import Throttling
    
    
    InfoThrottling = Throttling(rate=5, duration=timedelta(minutes=1))
    
    @API()
    async def hello_world():
        return {'detail': 'Hello World'}
    
    
    @API(cache=True, throttling=InfoThrottling)
    async def info(request: Request):
        data = {
            'version': version(),
            'datetime_now': datetime.now().isoformat(),
            'user_agent': request.headers.user_agent,
            'db_engine': config['db_engine'],
        }
        return Response(data=data, status_code=status.HTTP_202_ACCEPTED)
    
  • Then run the project:

    • $ cd myproject
    • $ panther run or $ panther run --reload

    now you can see these two urls:

Writing Your First CRUD: First CRUD


TODOs

  • Base
    • ✅ Start with Uvicorn
    • ✅ Fix URL Routing
    • ✅ Read Configs
    • ✅ Handle Exceptions
    • ✅ Add Custom Logger
    • ✅ Request Class
    • ✅ Response Class
    • ✅ Validate Input
    • ✅ Custom Output Model
    • ✅ Log Queries
    • ✅ Add Package Requirements
    • ✅ Custom Logging
    • ✅ Caching
    • ✅ Handle Path Variable
    • ✅ Handle Simple Form-Data
    • ✅ Handle Throttling
    • ✅ Handle ClassBase APIs
    • ☐ Handle Complex Form-Data
    • ☐ Handle File
    • ☐ Handle Cookie
    • ☐ Handle WS
    • ☐ Handle GraphQL
    • ☐ Handle Testing
    • ☐ Generate Swagger For APIs
  • Database
    • ✅ Structure Of DB Connection
    • ✅ PantherDB Connection
    • ✅ MongoDB Connection
    • ✅ Create Custom BaseModel For All Type Of Databases
    • ✅ Set PantherDB As Default
  • Custom ODM
    • ✅ Find One
    • ✅ Find
    • ✅ Last
    • ✅ Count
    • ✅ Insert One
    • ✅ Insert Many
    • ✅ Delete One
    • ✅ Delete Many
    • ✅ Delete Itself
    • ✅ Update One
    • ✅ Update Many
    • ✅ Update Itself
    • ✅ Find or Insert
    • ✅ Save
    • ☐ Find or Raise
    • ☐ Find with Pagination
    • ☐ Aggregation
    • ☐ Complex Pipelines
    • ☐ ...
  • Middleware
    • ✅ Add Middlewares To Structure
    • ✅ Create BaseMiddleware
    • ✅ Pass Custom Parameters To Middlewares
    • ✅ Handle Custom Middlewares
  • Authentication
    • ✅ JWT Authentication
    • ✅ Separate Auth For Every API
    • ✅ Handle Permissions
    • ☐ Token Storage Authentication
    • ☐ Cookie Authentication
    • ☐ Query Param Authentication
    • ☐ Store JWT After Logout In Redis/ Memory
  • Cache
    • ✅ Add Redis To Structure
    • ✅ Create Cache Decorator
    • ✅ Handle In-Memory Caching
    • ✅ Handle In Redis Caching
    • ☐ Write Async LRU_Caching With TTL (Replace it with in-memory ...)
  • CLI
    • ✅ Create Project
    • ✅ Run Project
    • ✅ Create Project with Options
    • ✅ Monitoring With Textual
    • ✅ Monitor Requests, Response & Time
  • Documentation
    • ✅ Create MkDocs For Project
    • ✅ Benchmarks
    • ✅ Release Notes
    • ✅ Features
    • ☐ Complete The MkDoc
  • Tests
    • ✅ Start Writing Tests For Panther
    • ☐ Test Client

Support

If you find this project useful, please give it a star ⭐️.

Project details


Release history Release notifications | RSS feed

This version

2.1.1

Download files

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

Source Distribution

panther-2.1.1.tar.gz (36.9 kB view details)

Uploaded Source

Built Distribution

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

panther-2.1.1-py3-none-any.whl (40.7 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: panther-2.1.1.tar.gz
  • Upload date:
  • Size: 36.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.9.17

File hashes

Hashes for panther-2.1.1.tar.gz
Algorithm Hash digest
SHA256 c34c022e1c0237452848fa5f0ec90b702a8b5c05fc493be6400409a9e6bb84c4
MD5 3f9fd3264c368042ef6184d2426e2b3c
BLAKE2b-256 c652074b6b79b58e26a77c3dab15b3da99885fca330db1dbcad75dbb126e42fa

See more details on using hashes here.

File details

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

File metadata

  • Download URL: panther-2.1.1-py3-none-any.whl
  • Upload date:
  • Size: 40.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.9.17

File hashes

Hashes for panther-2.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 2c4a2986ea24e21f4183d3a245fc6646e25f68db00f3c8b65ab5aae0583cd79c
MD5 c617aff9add1baebbdfda168b6fe8f65
BLAKE2b-256 0d63809443ba4ed2cb6d27ca33b36ffa0fc3385b022c19b807d15764b73bea92

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