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+
Features:
- Document-oriented Databases ORM (TinyDB, 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
Installation
-
Create a Virtual Environment
$ python -m venv .venv
-
Active The Environment
* Linux & Mac$ source .venv/bin/activate
* Windows$ .\.venv\Scripts\activate
-
Install Panther
$ pip install panter
or$ pip install panter[full] # include JWT Authentication
Usage
-
Create Project
$ panther create <project_name> <directory>
-
Monitoring Requests
$ panther monitor
-
Run Project
Panther needs Uvicorn as ASGI (Asynchronous Server Gateway Interface)$ pip install uvicorn[standard]
Then$ panther run
-
Python 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 panther import version, status from panther.app import API from panther.configs import config from panther.request import Request from panther.response import Response @API() async def hello_world(): return {'detail': 'Hello World'} @API() async def info(request: Request): data = { 'version': version(), 'debug': config['debug'], 'db_engine': config['db_engine'], 'default_cache_exp': config['default_cache_exp'], 'user_agent': request.headers.user_agent, 'content_length': request.headers.content_length, } return Response(data=data, status_code=status.HTTP_202_ACCEPTED)
-
Then run (
$ panther run
) the project, now you can see these two urls:
More examples: https://github.com/AliRn76/panther/tree/master/example.
TODO:
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 Form-Data
- Handle Cookie
- Handle File
- Handle WS
- Handle GraphQL
- Handle Throttling
- Handle Testing
Database:
- Structure Of DB Connection
- TinyDB Connection
- MongoDB Connection
- Create Custom BaseModel For All Type Of Databases
- Set TinyDB As Default
Custom ORM
- Get One
- List
- Create
- Delete
- Update
- Get or Raise
- Get or Create
- List with Pagination
- Other Queries In TinyDB
- Other Queries In MongoDB
Middleware
- Add Middlewares To Structure
- Create BaseMiddleware
- Pass Custom Parameters To Middlewares
- Import Custom Middlewares Of User
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
- Monitor Requests Response Time
- Create Project with Options
- Monitoring With Textual
Documentation
- Create MkDocs For Project
- Benchmarks
- Release Notes
- Features
- Complete The MkDoc
Tests
- Write Test For Panther
- Test ...
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-1.2.4.tar.gz
(28.1 kB
view hashes)
Built Distribution
panther-1.2.4-py3-none-any.whl
(34.0 kB
view hashes)