Skip to main content

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

GitHub: https://www.github.com/gonzageraci

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

zetta-backend-toolkit-0.1.3.tar.gz (6.2 kB view details)

Uploaded Source

Built Distribution

zetta_backend_toolkit-0.1.3-py3-none-any.whl (7.6 kB view details)

Uploaded Python 3

File details

Details for the file zetta-backend-toolkit-0.1.3.tar.gz.

File metadata

  • Download URL: zetta-backend-toolkit-0.1.3.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

Hashes for zetta-backend-toolkit-0.1.3.tar.gz
Algorithm Hash digest
SHA256 b1cb621bbebd1b5a1aa65b67eba7febb31ff2bb1b849a008307b5a24e3efbf66
MD5 28d01ba164e50195c6f2cb4cf58c1964
BLAKE2b-256 f38e0b60eb8dc1f5307614250cce6573f7bc1c9e244bd14381aee7f169392006

See more details on using hashes here.

File details

Details for the file zetta_backend_toolkit-0.1.3-py3-none-any.whl.

File metadata

File hashes

Hashes for zetta_backend_toolkit-0.1.3-py3-none-any.whl
Algorithm Hash digest
SHA256 4ed25da38d8ef4fb5cc48a808e3e8f69b457c5012b09b46948cee6da8c57bc0f
MD5 4a78027dc536bdf870e38a83338ffb0c
BLAKE2b-256 513a2a6d31bcc452d29f866f2a636f2df0bfa2876006ae2e49573abc15c551ca

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page