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

Uploaded Source

Built Distribution

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

Uploaded Python 3

File details

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

File metadata

  • Download URL: zetta-backend-toolkit-0.1.1.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.1.tar.gz
Algorithm Hash digest
SHA256 90271506780ba39d2edb6b3886778a8ae48ad1082243b09aaf08c4b214ff6236
MD5 9032b5a605bb6986eec7eee02175c8ca
BLAKE2b-256 4aa66db479df1351f59bc982d93006e26986b1922f9a877aca5020c7d8108a07

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for zetta_backend_toolkit-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 9d520d7b0fa1f7b8a8b140a904fb4fe21c4a1913fce602c25ed7bdf3cf7a2c78
MD5 2d81528f1743a0580f9db87809e3533d
BLAKE2b-256 704c80d703b30104214ff621f03bbb0474463aa85bc28779edaa336b5fd84240

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