/
api.py
42 lines (37 loc) · 1.18 KB
/
api.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
from flask import Flask, request, jsonify
from flask_cors import CORS, cross_origin
from controllers import mainprices
api = Flask(__name__)
cors=CORS(api)
api.config['CORS_HEADERS'] = 'Content-Type'
@api.route('/')
@cross_origin()
def get_generic():
return {
'/ticker/fundamentals/TICKER.sa':'Fundamentals (quarterly)',
'/ticker/cashflow/TICKER.sa':'Cashflow (quarterly)',
'/ticker/TICKER.sa':'Basic info about TICKSER.sa',
}, 200
@api.route('/ticker/<string:name>')
@cross_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>')
@cross_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>')
@cross_origin()
def get_cashflow_show(name):
result = mainprices.ShowMarket.cashflow_ticker(name)
if result:
return result, 200
return {'message':'not found'}, 404
if __name__ == '__main__':
api.run(port=5000, debug=True)