orgepo / panther

Fast & Friendly Python Web Framework

Home Page:https://pantherpy.github.io

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

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

Benchmark

Framework Throughput (Request/Second)
Blacksheep 5,339
Muffin 5,320
Panther 5,112
Sanic 3,660
FastAPI 3,260
Tornado 2,081
Bottle 2,045
Django 821
Flask 749

More Detail: https://github.com/PantherPy/frameworks-benchmark


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.url_routing'

    core/urls.py:

    from app.urls import urls as app_urls
    
    url_routing = {
        '/': 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 File
    • ✅ Handle Huge Files
    • ☐ 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 ⭐️.

About

Fast & Friendly Python Web Framework

https://pantherpy.github.io

License:BSD 3-Clause "New" or "Revised" License


Languages

Language:Python 100.0%