Spaces:
Running
Running
File size: 783 Bytes
85b7206 0700cb3 85b7206 0700cb3 85b7206 0700cb3 85b7206 0700cb3 85b7206 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
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)
|