carpeadiam commited on
Commit
79b0d58
·
verified ·
1 Parent(s): 69dbc45

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +40 -0
app.py ADDED
@@ -0,0 +1,40 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from flask import Flask, jsonify, request, make_response, session
2
+ from StockSentimentAnalyser import StockSentimentAnalyzer
3
+ from StockSentimentNews import mainOne
4
+
5
+
6
+ app = Flask(__name__)
7
+ app.config['SECRET_KEY'] = 'your-secret-key-here'
8
+ CORS(app)
9
+
10
+
11
+
12
+
13
+ @app.route('/api/sentimental_summary', methods=['GET'])
14
+ def get_sentimental_summary():
15
+ try:
16
+ symbol = request.args.get('symbol')
17
+ company_name = request.args.get('company_name', None)
18
+ analyzer = StockSentimentAnalyzer()
19
+ analysis = analyzer.get_comprehensive_analysis(symbol, company_name)
20
+ return jsonify(analysis)
21
+ except Exception as e:
22
+ return jsonify({'error': str(e)}), 500
23
+
24
+ @app.route('/api/sentimental_analysis', methods=['GET'])
25
+ def get_sentimental_analysis():
26
+ try:
27
+ symbol = request.args.get('symbol')
28
+ if not symbol:
29
+ return jsonify({'error': 'Symbol parameter is required'}), 400
30
+ querystring = {'name': symbol}
31
+ results = mainOne(querystring)
32
+ return jsonify(results)
33
+ except Exception as e:
34
+ return jsonify({'error': str(e)}), 500
35
+
36
+
37
+
38
+
39
+ if __name__ == '__main__':
40
+ app.run(debug=True)