Skip to content

Commit

Permalink
Merge pull request #40 from raulc27/dev
Browse files Browse the repository at this point in the history
fix: cors, flask_cors
  • Loading branch information
raulc27 committed Apr 18, 2024
2 parents 8f1e3b2 + be91783 commit b9b3262
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
7 changes: 6 additions & 1 deletion api.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
from flask import Flask, request, jsonify
from flask_cors import CORS
from controllers import mainprices

api = Flask(__name__)

CORS(api)
@api.route('/')
@cors_origin()
def get_generic():
return {
'/ticker/fundamentals/TICKER.sa':'Fundamentals (quarterly)',
Expand All @@ -12,20 +14,23 @@ def get_generic():
}, 200

@api.route('/ticker/<string:name>')
@cors_origin()
def get_show(name):
result = mainprices.ShowMarket.show_ticker(name)
if result:
return result, 200
return {'message':'not found'}, 404

@api.route('/ticker/fundamentals/<string:name>')
@cors_origin()
def get_fundamentals_show(name):
result = mainprices.ShowMarket.fundamentals_ticker(name)
if result:
return result, 200
return {'message':'not found'}, 404

@api.route('/ticker/cashflow/<string:name>')
@cors_origin()
def get_cashflow_show(name):
result = mainprices.ShowMarket.cashflow_ticker(name)
if result:
Expand Down
1 change: 1 addition & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -22,3 +22,4 @@ Werkzeug==2.0.2
yfinance==0.2.37
zipp==3.7.
gevent==23.9.1
flask-cors==4.0.0

0 comments on commit b9b3262

Please sign in to comment.