stock-agent/web/app.py
2025-12-28 10:12:30 +08:00

35 lines
989 B
Python

from flask import Flask, render_template, jsonify, request
import requests
import json
app = Flask(__name__)
# API配置
API_BASE_URL = "http://localhost:8000/api"
@app.route('/')
def index():
return render_template('index.html')
@app.route('/api/screen', methods=['POST'])
def screen_stocks():
"""股票筛选代理接口"""
try:
data = request.json
response = requests.post(f"{API_BASE_URL}/screen", json=data)
return jsonify(response.json()), response.status_code
except Exception as e:
return jsonify({'error': str(e)}), 500
@app.route('/api/analyze', methods=['POST'])
def analyze_stock():
"""单股分析代理接口"""
try:
data = request.json
response = requests.post(f"{API_BASE_URL}/analyze", json=data)
return jsonify(response.json()), response.status_code
except Exception as e:
return jsonify({'error': str(e)}), 500
if __name__ == '__main__':
app.run(debug=True, port=5001)