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.11+

logo

logo Supported by JetBrains

Full Documentation: PantherPy.GitHub.io


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

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.4.tar.gz (39.0 kB view hashes)

Uploaded Source

Built Distribution

panther-2.1.4-py3-none-any.whl (41.3 kB view hashes)

Uploaded Python 3

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