changeset 110 | 7af0b8ce698f |
parent 108 | e77b7c324a32 |
child 111 | 530d215d5df1 |
--- a/qmsk/web/json.py Fri Jan 30 14:05:12 2015 +0200 +++ b/qmsk/web/json.py Fri Jan 30 14:05:20 2015 +0200 @@ -3,6 +3,16 @@ class JSONMixin: MIMETYPE = 'application/json' + CORS_ORIGIN = None + CORS_METHODS = None + + def headers (self): + if self.CORS_ORIGIN: + yield 'Access-Control-Allow-Origin', self.CORS_ORIGIN + + if self.CORS_METHODS: + yield 'Access-Control-Allow-Methods', ', '.join(self.CORS_METHODS) + def render_json(self, **parms): raise NotImplementedError()