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+
Full Documentation -> https://pantherpy.github.io
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
Benchmark
We implemented most of the Python frameworks and sent
60_000
requests per second
for a total of 10
seconds
(Total 600_000
requests)
in the same environment
with https://github.com/nakabonne/ali and here's the result:
we won't rate other frameworks with throughput, so the names are censored. but you can find the detailed results & source codes [here]
Framework | Request Handled | Max Latencies |
---|---|---|
... | 275,060 | 270.3ms |
... | 188,016 | 195.6ms |
Panther | 156,743 | 214.7ms |
... | 66,274 | 476.2ms |
... | 52,350 | 1.2924s |
... | 32,944 | 30.00ms |
... | 31,336 | 30.03ms |
... | 19,820 | 30.0s |
Installation
-
Create a Virtual Environment
$ python -m venv .venv
-
Active The Environment
* Linux & Mac$ source .venv/bin/activate
* Windows$ .\.venv\Scripts\activate
-
Install Panther
* Normal$ pip install panther
* Include JWT Authentication$ pip install panther[full]
Usage
-
Create Project
$ panther create <project_name> <directory>
-
Run Project
Panther needs Uvicorn as ASGI (Asynchronous Server Gateway Interface)
$ pip install uvicorn[standard]
Then
$ panther run
-
Monitoring Requests
$ panther monitor
-
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.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(), '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.
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.