python - How do I get flask-cor to return Access-Control-Allow-Origin on Google App Engine? -


my python app not throw errors on google app engine, allow-control-access-origin header never sent. how can ensure sending flask-cors?

import mysqldb import os import webapp2 import json import flask flask import flask, jsonify, render_template, request flask.ext.cors import cors, cross_origin  app = flask(__name__)  @app.route('/') @cross_origin()     def do_search():   if (os.getenv('server_software') ,     os.getenv('server_software').startswith('google app engine/')):     db = mysqldb.connect(unix_socket='/cloudsql/my-instance-name:storeaddressdb', db='store_locator', user='myuser', passwd='password')   else:     db = mysqldb.connect(host='localhost', user='root')    cursor = db.cursor()    query = 'select * stores 1 limit 5'   cursor.execute(query)   resp = jsonify(data=cursor.fetchall())   return resp    db.close() 

it appears code work, although not see allow-control-access-origin header when use curl test url. logs in google app engine show cors selectively adding header unless client skipped it. also, javascript client no longer showing error, , receives data. may not prettiest python code, functionally correct purposes.


Comments

Popular posts from this blog

javascript - oscilloscope of speaker input stops rendering after a few seconds -

javascript - gulp-nodemon - nodejs restart after file change - Error: listen EADDRINUSE events.js:85 -

Fatal Python error: Py_Initialize: unable to load the file system codec. ImportError: No module named 'encodings' -