FastHttpPy
Python implementation of Golang FastHttp
63k requests/second (for comparisons the fastest Python server (uvicorn) does 8k/s without multiprocess)
Benchmark made on MacBook Pro M2 Pro
pip install fasthttppy
Example:
from fasthttppy import FastHttp, MakeResponse, Request
app = FastHttp()
app.Static("/static","static")
def my_callback(req:Request):
print(req.contents.GetURI())
print(req.contents.GetHeaders())
print(req.contents.GetData())
return MakeResponse(200,"Hello world")
app.Get("/py",my_callback)
app.Post("/py",my_callback)
app.Run()
Methods:
class FastHttp:
def Static(self,path:str,dir:str)
#=-=-=Serve static folder=-=-=
#path: url path
#dir: folder
#=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
def Get(self,path:str,function:Callable)
#=-=-Bind path to function-=-=
#path: url path
#function: function
#=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
def Post(self,path:str,function:Callable)
#=-=-Bind path to function-=-=
#path: url path
#function: function
#=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
def SetErrorPage(self,content:str)
#=-=-=-=Set error page-=-=-=-=
#content: html content
#=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
def SetNotFoundPage(self,path:str,dir:str)
#=-=-=-=-Set 404 page=-=-=-=-=
#content: html content
#=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
def Run(self,host:str,port:int)
#=-=-=-=Start Go server=-=-=-=
#host: server host
#port: server port
#=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
It is still possible to improve performance a lot, the golang/py communication is done through a *C.char Json that can be replaced by structs (removing the json encode decode step)
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
fasthttppy-0.0.2.tar.gz
(6.0 kB
view details)
File details
Details for the file fasthttppy-0.0.2.tar.gz.
File metadata
- Download URL: fasthttppy-0.0.2.tar.gz
- Upload date:
- Size: 6.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via:
twine/4.0.2 CPython/3.11.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
db95a970ced204c7579174de51e7e2187f55e80e4a5a4378a78237592d8b9dbe
|
|
| MD5 |
5d65f09dfb2f25b49ef997f3a589cedd
|
|
| BLAKE2b-256 |
353686f1cdbc863f79f40b09e2d9ddc015c896b6a6ab6a3fc0ed359454c7ead7
|