From 226441d82111b70d5b5b69459fa48bd294e97d97 Mon Sep 17 00:00:00 2001 From: pictuga Date: Sat, 28 Jun 2014 00:59:13 +0200 Subject: [PATCH] Add :cors for cross-domain XHR (with README update) --- README.md | 1 + morss/morss.py | 3 +++ 2 files changed, 4 insertions(+) diff --git a/README.md b/README.md index b6b3ca3..8c78006 100644 --- a/README.md +++ b/README.md @@ -50,6 +50,7 @@ The arguments are: - `theforce`: force download the rss feed - `silent`: don't output the final RSS (useless on its own, but can be nice when debugging) - http server only + - `cors`: allow Cross-origin resource sharing (allows XHR calls from other servers) - `html`: changes the http content-type to html, so that python cgi erros (written in html) are readable in a web browser - `txt`: changes the http content-type to txt (for faster "`view-source:`") - `force`: avoid using your browser cache (do not support 304 errors) diff --git a/morss/morss.py b/morss/morss.py index cc0b6ca..d6291d4 100644 --- a/morss/morss.py +++ b/morss/morss.py @@ -757,6 +757,9 @@ def cgi_app(environ, start_response): headers['status'] = '200 OK' headers['etag'] = '"%s"' % int(time.time()) + if options.cors: + headers['access-control-allow-origin'] = '*' + if options.html or options.reader: headers['content-type'] = 'text/html' elif options.debug or options.txt: