author | Tero Marttila <terom@paivola.fi> |
Fri, 30 Jan 2015 14:05:20 +0200 | |
changeset 110 | 7af0b8ce698f |
parent 109 | 55f6a253cc15 |
child 111 | 530d215d5df1 |
qmsk/web/json.py | file | annotate | diff | comparison | revisions |
--- 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()