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.2.tar.gz (6.2 kB view details)

Uploaded Source

Built Distribution

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

Uploaded Python 3

File details

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

File metadata

  • Download URL: zetta-backend-toolkit-0.1.2.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.2.tar.gz
Algorithm Hash digest
SHA256 37421bddf3bb52914c94fdb1856e665bd8f64ad94012b382e442175c60ad0077
MD5 fcb57e53005f8a2848737b5261f733f2
BLAKE2b-256 f00cacf691283e2a5473861b7d147d4e042edafa89bf091bb6cd692bfb778c57

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for zetta_backend_toolkit-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 362bcbf80092f09e7c1d25b35c7f52ec9a337f743a413fc3d75037bf9644c312
MD5 c2dd73ec8db77c366d19837a6409fde7
BLAKE2b-256 e8d8f5d2efd5dbcfd817e993236ada65f70a257a1630782ea9e4cc80895c76e2

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