def add_column_certain_matches(project_id):
'''
Specify certain column matches (exact match on a subset of columns equivalent
to entity identity). This is used to test performances.
wrapper around ESLinker.add_col_certain_matches
GET:
- project_id: ID for "link" project
POST:
- column_certain_matches: {dict object}: (see doc in original function)
'''
column_matches = request.json['column_certain_matches']
proj = ESLinker(project_id=project_id)
proj.add_col_certain_matches(column_matches)
return jsonify(error=False)
#@app.route('/api/link/add_columns_to_return/<project_id>/<file_role>/', methods=['POST'])
#@cross_origin()
#def add_columns_to_return(project_id, file_role):
# '''
# Specify columns to be included in download version of file. For link project
#
# # TODO: shouldn't this be for normalize also ?
#
# wrapper around ESLinker.add_cols_to_return
#
# GET:
# project_id: ID for "link" project
# file_role: "ref" or "source"
# '''
# columns_to_return = request.json
# proj = ESLinker(project_id=project_id)
# proj.add_cols_to_return(file_role, columns_to_return)
# return jsonify(error=False)
python类cross_origin()的实例源码
api.py 文件源码
项目:the-magical-csv-merge-machine
作者: entrepreneur-interet-general
项目源码
文件源码
阅读 28
收藏 0
点赞 0
评论 0
def crossdomain(*args, **kwargs):
return (cross_origin)
####################
## app decorators ##
####################
def cors(*args, **kwargs):
"""
A wrapper around flask-cors cross_origin, to also act on classes
**An extra note about cors, a response must be available before the
cors is applied. Dynamic return is applied after the fact, so use the
decorators, json, xml, or return self.render() for txt/html
ie:
@cors()
class Index(Mocha):
def index(self):
return self.render()
@json
def json(self):
return {}
class Index2(Mocha):
def index(self):
return self.render()
@cors()
@json
def json(self):
return {}
:return:
"""
def decorator(fn):
cors_fn = flask_cors.cross_origin(automatic_options=False, *args, **kwargs)
if inspect.isclass(fn):
apply_function_to_members(fn, cors_fn)
else:
return cors_fn(fn)
return fn
return decorator