mirror of
https://github.com/beetbox/beets.git
synced 2026-01-30 03:54:21 +01:00
Combined cors and cors_origin config options into one
This commit is contained in:
parent
47ea4b7d8b
commit
f815138758
1 changed files with 6 additions and 6 deletions
|
|
@ -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)
|
||||
|
|
|
|||
Loading…
Reference in a new issue