我希望Google api这样显示我的业务:
import flask
import main_function as mf
from flask_cors import CORS,cross_origin
app = flask.Flask(__name__)
CORS(app)
app.config["DEBUG"] = True
@app.route('/api/v1.0/second_page/<ticker>/<doc_type>/<selection>',methods=['GET'])
def get_aggregated_past_data_for_selection(ticker,selection,doc_type):
num_iter = 0
new_ticker_flag = True
if ticker and doc_type and selection:
final_value_dict = mf.combine_past_data(ticker,doc_type,selection,num_iter,new_ticker_flag,calling_from='api')
response = flask.jsonify(final_value_dict)
response.headers.add('Access-Control-Allow-Origin', 'http://localhost:4200')
return response
else:
return flask.jsonify({"Error": “Some fields missing. Please try againr."})
if __name__ == '__main__':
app.run(host='0.0.0.0')
Access to XMLHttpRequest at 'http://192.168.1.14:5000/api/v1.0/second_page/AAPL/10-K/24_2_5' from origin 'http://localhost:4200' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource.