Spaces:
Running
Running
from flask import Flask, jsonify, request, make_response, session | |
from flask_cors import CORS | |
from StockSentimentAnalyser import StockSentimentAnalyzer | |
from StockSentimentNews import mainOne | |
app = Flask(__name__) | |
app.config['SECRET_KEY'] = 'your-secret-key-here' | |
CORS(app) | |
def get_sentimental_summary(): | |
try: | |
symbol = request.args.get('symbol') | |
company_name = request.args.get('company_name', None) | |
analyzer = StockSentimentAnalyzer() | |
analysis = analyzer.get_comprehensive_analysis(symbol, company_name) | |
return jsonify(analysis) | |
except Exception as e: | |
return jsonify({'error': str(e)}), 500 | |
def get_sentimental_analysis(): | |
try: | |
symbol = request.args.get('symbol') | |
if not symbol: | |
return jsonify({'error': 'Symbol parameter is required'}), 400 | |
querystring = {'name': symbol} | |
results = mainOne(querystring) | |
return jsonify(results) | |
except Exception as e: | |
return jsonify({'error': str(e)}), 500 | |
if __name__ == '__main__': | |
app.run(host="0.0.0.0", port=7860, debug=False) # Disable debug for production |