Add CORS header

This commit is contained in:
redfast00 2019-03-21 21:35:00 +01:00
parent e0ced162f4
commit 6bb2c6e2e5
No known key found for this signature in database
GPG key ID: 5946E0E34FD0553C

View file

@ -195,13 +195,15 @@ def list_quotes():
@app.route('/quotes.json', methods=['GET'])
def json_quotes():
all_quotes = models.Quote.query.all()
return jsonify(list({
response = jsonify(list({
'quoter': q.quoter,
'quotee': q.quotee,
'channel': q.channel,
'quote': q.quote,
'created_at': q.created_at.isoformat()
} for q in all_quotes))
response.headers.add('Access-Control-Allow-Origin', '*')
return response
RESTO_TEMPLATE = """
# Resto menu
@ -256,5 +258,3 @@ def resto_menu():
@app.route('/resto.json', methods=['GET'])
def resto_menu_json():
return mattermost_response(resto_menu(), ephemeral=True)