diff --git a/beetsplug/web/__init__.py b/beetsplug/web/__init__.py index 5a78b5042..cc1666d38 100644 --- a/beetsplug/web/__init__.py +++ b/beetsplug/web/__init__.py @@ -23,8 +23,8 @@ from werkzeug.routing import BaseConverter, PathConverter import os import json -# Utilities. +# Utilities. def _rep(obj, expand=False): """Get a flat -- i.e., JSON-ish -- representation of a beets Item or @@ -256,8 +256,7 @@ class WebPlugin(BeetsPlugin): self.config.add({ 'host': u'127.0.0.1', 'port': 8337, - 'cors': False, - 'cors_origin': '*', + 'cors': '', }) def commands(self): @@ -273,15 +272,16 @@ class WebPlugin(BeetsPlugin): self.config['port'] = int(args.pop(0)) app.config['lib'] = lib - - # Enable CORS if required + # Enable CORS if required. if self.config['cors']: + print "Enabling cors" from flask.ext.cors import CORS app.config['CORS_ALLOW_HEADERS'] = "Content-Type" app.config['CORS_RESOURCES'] = { - r"/*": {"origins": self.config['cors_origin'].get(str)} + r"/*": {"origins": self.config['cors'].get(str)} } CORS(app) + # Start the web application. app.run(host=self.config['host'].get(unicode), port=self.config['port'].get(int), debug=opts.debug, threaded=True)