# HG changeset patch # User Tero Marttila # Date 1422619520 -7200 # Node ID 7af0b8ce698f120ae1e49f194531ca143352b30a # Parent 55f6a253cc155de62f3913c2c405abddf2245e6d qmsk.web.json: CORS_ORIGIN/CORS_METHODS diff -r 55f6a253cc15 -r 7af0b8ce698f qmsk/web/json.py --- 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()