Estructura inicial funcional con documentación en el README.md de la FastAPI

This commit is contained in:
2026-09-25 11:20:50 -03:00
parent edc71742fa
commit 774e227642
2710 changed files with 1012769 additions and 0 deletions

View File

@@ -0,0 +1,28 @@
# Copyright: (c) 2019, Jordan Borean (@jborean93) <jborean93@gmail.com>
# MIT License (see LICENSE or https://opensource.org/licenses/MIT)
def to_bytes(value, encoding="utf-8"):
"""
Makes sure the value is encoded as a byte string.
:param value: The Python string value to encode.
:param encoding: The encoding to use.
:return: The byte string that was encoded.
"""
if isinstance(value, bytes):
return value
return value.encode(encoding)
def to_text(value, encoding="utf-8"):
"""
Makes sure the value is decoded as a text string.
:param value: The Python byte string value to decode.
:param encoding: The encoding to use.
:return: The text/unicode string that was decoded.
"""
if isinstance(value, str):
return value
return value.decode(encoding)