Metis/app/controller/render.py
2018-11-07 14:57:17 +08:00

12 lines
459 B
Python

import json
from django.http import HttpResponse
def render_json(dictionary=None):
dictionary = {} if dictionary is None else dictionary
response = HttpResponse(json.dumps(dictionary), content_type="application/json")
response['Access-Control-Allow-Origin'] = '*'
response["Access-Control-Allow-Headers"] = "Origin, X-Requested-With, Content-Type"
response["Access-Control-Allow-Methods"] = "GET, POST, PUT, OPTIONS"
return response