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  fastapi-toolkit

Logger Middleware

To use the logging middleware, simply add it to your FastAPI application:

from fastapi import FastAPI
from fastapi_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 fastapi_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 fastapi_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.0.tar.gz (6.2 kB view details)

Uploaded Source

Built Distribution

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

Uploaded Python 3

File details

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

File metadata

  • Download URL: zetta-backend-toolkit-0.1.0.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.0.tar.gz
Algorithm Hash digest
SHA256 75f723115112f5f52ba9b942f355b4393f0463ffc5e023bc24993c7f60c6040b
MD5 b9d5a796083e04ba38ce6a0595f66c53
BLAKE2b-256 e980974c2eba767d148901a4411b090e73b0f5968c323b7e0a7e5bccf71bf51a

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for zetta_backend_toolkit-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 f3406330909b1aa68b4d8567c12af0ac56dea80e7af8a6a71cbbd9b6d9dca8e3
MD5 1e98efa50ab958a828db7670fb92e62c
BLAKE2b-256 e4324f7d107aaa1e85bf4d697b6c07d4b74aadb2c4aad5152ea375978c131e05

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