ai-pronunciation-trainer / utilsFileIO.py
alessandro trinca tornidor
doc: add/update docstring and typing hints
0700cb3
raw
history blame contribute delete
783 Bytes
import string
import random
from flask import Response
from constants import ALLOWED_ORIGIN
headers = {
'Access-Control-Allow-Headers': ALLOWED_ORIGIN,
'Access-Control-Allow-Origin': ALLOWED_ORIGIN,
'Access-Control-Allow-Methods': 'OPTIONS,POST,GET'
}
def generateRandomString(str_length: int = 20) -> str:
# printing lowercase
letters = string.ascii_lowercase
return ''.join(random.choice(letters) for i in range(str_length))
def return_response(body, mimetype="application/json", status=200) -> Response:
return Response(
response=body,
status=status,
mimetype=mimetype,
headers=headers
)
def return_response_ok(body, mimetype="application/json") -> Response:
return return_response(body, mimetype, 200)