18 lines
518 B
Python
18 lines
518 B
Python
import json
|
|
from datetime import datetime, timezone
|
|
|
|
def create_respone(translated, from_code, to_code, error):
|
|
# Creating a dictionary that matches the structure of your JSON
|
|
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)
|
|
|