This commit is contained in:
a_voel02 2018-10-21 16:09:48 +02:00
parent ea653b6840
commit e93bc2f828

16
main.py
View File

@ -323,6 +323,21 @@ for app in config.Apps:
runner = AppRunner()
runner.start()
@bottle.route('/<:re:.*>', method='OPTIONS')
def enable_cors_generic_route():
add_cors_headers()
@bottle.hook('after_request')
def enable_cors_after_request_hook():
add_cors_headers()
def add_cors_headers():
bottle.response.headers['Access-Control-Allow-Origin'] = '*'
bottle.response.headers['Access-Control-Allow-Methods'] = \
'GET, POST, PUT, OPTIONS'
bottle.response.headers['Access-Control-Allow-Headers'] = \
'Origin, Accept, Content-Type, X-Requested-With, X-CSRF-Token'
@route("/apps/list")
def apps_list():
s = []
@ -380,6 +395,7 @@ def setGamma(r, g, b):
g = float(g)
b = float(b)
runner.setGamma(r, g, b)
return "ok"
run(host=config.WebHost, port=config.WebPort)
running = False