Fast & Friendly, Web Framework For Building Async APIs
Project description
Panther
Is A Fast & Friendly Web Framework For Building Async APIs With Python 3.10+
Supported by JetBrains
Full Documentation: PantherPy.GitHub.io
Why Use Panther ?
- Document-oriented Databases ODM (PantherDB, MongoDB)
- Built-in Websocket Support
- Cache APIs (In Memory, In Redis)
- Built-in Authentication Classes (Customizable)
- Built-in Permission Classes (Customizable)
- Handle Custom Middlewares
- Handle Custom Throttling
- Visual API Monitoring (In Terminal)
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 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 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 = { 'panther_version': version(), 'datetime_now': datetime.now().isoformat(), 'user_agent': request.headers.user_agent } 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:
Next Step: First CRUD
Real Word Example: Https://GitHub.com/PantherPy/panther-example
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-3.2.3.tar.gz
(48.2 kB
view hashes)
Built Distribution
panther-3.2.3-py3-none-any.whl
(50.5 kB
view hashes)