Is A Fast & Friendly Web Framework For Building Async APIs With Python 3.11+
Supported by JetBrain
Full Documentation: https://pantherpy.github.io
PyPI: https://pypi.org/project/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
-
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]
-
$ panther create <project_name> <directory>
-
Panther uses Uvicorn as ASGI (Asynchronous Server Gateway Interface)
$ panther run
-
$ panther monitor
-
Panther Uses bpython for shell
$ panther shell
-
$ panther create myproject
-
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
If you find this project useful, please give it a star ⭐️.