Un toolkit Backend para FastAPI
Project description
FastAPI Toolkit
FastAPI Toolkit is a set of tools to enhance the development of applications with FastAPI. It includes middleware for logging, request rate limiting, and more.
Installation
You can install the package using pip:
pip install zetta-backend-toolkit
Logger Middleware
To use the logging middleware, simply add it to your FastAPI application:
from fastapi import FastAPI
from zetta-backend-toolkit.logger_middleware import LoggerMiddleware
app = FastAPI()
app.add_middleware(LoggerMiddleware)
@app.get("/")
async def read_root():
return {"message": "Hello World"}
Rate Limiting Middleware
To limit the number of requests per IP:
from fastapi import FastAPI
from zetta-backend-toolkit.rate_limit_middleware import RateLimitMiddleware
app = FastAPI()
app.add_middleware(RateLimitMiddleware, max_requests=5, period=60)
@app.get("/")
async def read_root():
return {"message": "Hello World"}
Translation Middleware
To translate requests and responses using googletrans:
from fastapi import FastAPI, Request
from zetta-backend-toolkit.translation_middleware import TranslationMiddleware
app = FastAPI()
app.add_middleware(TranslationMiddleware, target_language="en")
@app.post("/translate")
async def translate_text(request: Request):
body = await request.body()
return {"translated_text": body.decode("utf-8")}
Project Information
Name: fastapi-toolkit
Version: 0.1.0
Author: Gonzalo Geraci
Author's Email: gonza.geraci@gmail.com
Description: A Backend toolkit for FastAPI
Project URL: https://github.com/gonzageraci/FastAPI-toolkit
Requires Python: >=3.10
Dependencies:
- fastapi
Contribute
Contributions are welcome. Please open an issue or a pull request on the GitHub repository.
License
This project is licensed under the MIT License. See the LICENSE file for more details.
Contact
Author: Gonzalo Geraci
Email: gonza.geraci@gmail.com
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file zetta-backend-toolkit-0.1.4.tar.gz
.
File metadata
- Download URL: zetta-backend-toolkit-0.1.4.tar.gz
- Upload date:
- Size: 6.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.10.11
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 1ec269bf445486c76b2f1955f14e0e2842414fb81002ece757220e876cb0ad9b |
|
MD5 | 8a0e5c8a665ab0fb75f6937709259a1d |
|
BLAKE2b-256 | 55090ef322f4282fce11534b7d63d3c51b1a0e6741f0b4d876edbb01eb82382d |
File details
Details for the file zetta_backend_toolkit-0.1.4-py3-none-any.whl
.
File metadata
- Download URL: zetta_backend_toolkit-0.1.4-py3-none-any.whl
- Upload date:
- Size: 7.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.10.11
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | d2538696ac070299dabcb95fa64c7cf9dee3e1513c2376ddb43c35179004c482 |
|
MD5 | 8f1bcf0ceaa18d0eea957043e9bba528 |
|
BLAKE2b-256 | b4c4c7456b533f7b0171955806af5e4b1585800c9de32453cd80bc013a5f7e9f |