66 lines
1.8 KiB
Python
66 lines
1.8 KiB
Python
"""
|
|
股票投资分析系统 - 主应用入口
|
|
"""
|
|
from flask import Flask, render_template, jsonify
|
|
from flask_cors import CORS
|
|
from config import Config
|
|
|
|
# 初始化配置
|
|
Config.init_app()
|
|
|
|
# 创建Flask应用
|
|
app = Flask(__name__, template_folder='templates', static_folder='static')
|
|
app.config['SECRET_KEY'] = Config.SECRET_KEY
|
|
CORS(app, supports_credentials=True)
|
|
|
|
# 注册路由蓝图
|
|
from routes.auth import bp as auth_bp
|
|
from routes.trades import bp as trades_bp
|
|
from routes.watchlist import bp as watchlist_bp
|
|
from routes.analysis import bp as analysis_bp
|
|
from routes.market import bp as market_bp
|
|
from routes.sim_trade import bp as sim_trade_bp
|
|
from routes.admin import bp as admin_bp
|
|
from routes.smart_trade import bp as smart_trade_bp
|
|
|
|
app.register_blueprint(auth_bp)
|
|
app.register_blueprint(trades_bp)
|
|
app.register_blueprint(watchlist_bp)
|
|
app.register_blueprint(analysis_bp)
|
|
app.register_blueprint(market_bp)
|
|
app.register_blueprint(sim_trade_bp)
|
|
app.register_blueprint(admin_bp)
|
|
app.register_blueprint(smart_trade_bp)
|
|
|
|
|
|
# ========== 基础路由 ==========
|
|
|
|
@app.route('/')
|
|
def index():
|
|
"""首页"""
|
|
return render_template('index.html')
|
|
|
|
|
|
@app.route('/api/health', methods=['GET'])
|
|
def health():
|
|
"""健康检查"""
|
|
return jsonify({'status': 'ok', 'message': '服务运行正常'})
|
|
|
|
|
|
# ========== 启动 ==========
|
|
|
|
if __name__ == '__main__':
|
|
print("=" * 60)
|
|
print("股票投资分析系统启动")
|
|
print("=" * 60)
|
|
print(f"Web界面: http://localhost:{Config.PORT}")
|
|
print(f"API地址: http://localhost:{Config.PORT}/api/")
|
|
print(f"健康检查: http://localhost:{Config.PORT}/api/health")
|
|
print("=" * 60)
|
|
|
|
# 启动模拟交易定时任务调度器
|
|
from services.scheduler import start_scheduler
|
|
start_scheduler()
|
|
|
|
app.run(debug=True, host='0.0.0.0', port=Config.PORT)
|