2024-03-13 17:58:13 +00:00
|
|
|
import json
|
|
|
|
from datetime import datetime, timezone
|
|
|
|
|
|
|
|
def create_respone(translated, from_code, to_code, error):
|
2024-03-13 20:40:34 +00:00
|
|
|
# Creating a dictionary that matches the structure of your JSON
|
2024-03-13 17:58:13 +00:00
|
|
|
data = {
|
|
|
|
"from": from_code,
|
|
|
|
"to": to_code,
|
|
|
|
"created_at": datetime.now(timezone.utc).strftime("%Y-%m-%dT%H:%M:%S.%f%z"),
|
|
|
|
"response": translated,
|
|
|
|
"error": error
|
|
|
|
}
|
|
|
|
json_string = json.dumps(data, indent=4)
|
|
|
|
|
|
|
|
# Printing the JSON string to the console
|
|
|
|
print(json_string)
|
|
|
|
|
2024-03-13 20:40:34 +00:00
|
|
|
|