update pay ui
This commit is contained in:
9
app.py
9
app.py
@@ -7297,6 +7297,15 @@ def get_index_realtime(index_code):
|
||||
从 index_minute 表获取最新的分钟数据
|
||||
返回: 最新价、涨跌幅、涨跌额、开盘价、最高价、最低价、昨收价
|
||||
"""
|
||||
# 确保指数代码包含后缀(ClickHouse 中存储的是带后缀的代码)
|
||||
# 上证指数: 000xxx.SH, 深证指数: 399xxx.SZ
|
||||
if '.' not in index_code:
|
||||
if index_code.startswith('399'):
|
||||
index_code = f"{index_code}.SZ"
|
||||
else:
|
||||
# 000开头的上证指数,以及其他指数默认上海
|
||||
index_code = f"{index_code}.SH"
|
||||
|
||||
client = get_clickhouse_client()
|
||||
today = date.today()
|
||||
|
||||
|
||||
34
app_vx.py
34
app_vx.py
@@ -597,14 +597,36 @@ JWT_SECRET_KEY = 'vfllmgreat33818!' # 请修改为安全的密钥
|
||||
JWT_ALGORITHM = 'HS256'
|
||||
JWT_EXPIRATION_HOURS = 24 * 7 # Token有效期7天
|
||||
|
||||
# Session 配置 - 使用文件系统存储(替代 Redis)
|
||||
app.config['SESSION_TYPE'] = 'filesystem'
|
||||
app.config['SESSION_FILE_DIR'] = os.path.join(os.path.dirname(__file__), 'flask_session')
|
||||
# Session 配置
|
||||
# 优先使用 Redis(支持多 worker 共享),否则回退到文件系统
|
||||
_REDIS_URL = os.environ.get('REDIS_URL', 'redis://localhost:6379/0')
|
||||
_USE_REDIS_SESSION = os.environ.get('USE_REDIS_SESSION', 'true').lower() == 'true'
|
||||
|
||||
try:
|
||||
if _USE_REDIS_SESSION:
|
||||
import redis
|
||||
# 测试 Redis 连接
|
||||
_redis_client = redis.from_url(_REDIS_URL)
|
||||
_redis_client.ping()
|
||||
|
||||
app.config['SESSION_TYPE'] = 'redis'
|
||||
app.config['SESSION_REDIS'] = _redis_client
|
||||
app.config['SESSION_KEY_PREFIX'] = 'vf_session:'
|
||||
logger.info(f"✅ Session 存储: Redis ({_REDIS_URL})")
|
||||
else:
|
||||
raise Exception("Redis session disabled by config")
|
||||
except Exception as e:
|
||||
# Redis 不可用,回退到文件系统
|
||||
logger.warning(f"⚠️ Redis 不可用 ({e}),使用文件系统 session(多 worker 模式下可能不稳定)")
|
||||
app.config['SESSION_TYPE'] = 'filesystem'
|
||||
app.config['SESSION_FILE_DIR'] = os.path.join(os.path.dirname(__file__), 'flask_session')
|
||||
os.makedirs(app.config['SESSION_FILE_DIR'], exist_ok=True)
|
||||
|
||||
app.config['SESSION_PERMANENT'] = True
|
||||
app.config['PERMANENT_SESSION_LIFETIME'] = timedelta(days=7) # Session 有效期 7 天
|
||||
|
||||
# 确保 session 目录存在
|
||||
os.makedirs(app.config['SESSION_FILE_DIR'], exist_ok=True)
|
||||
app.config['SESSION_COOKIE_SECURE'] = False # 生产环境 HTTPS 时设为 True
|
||||
app.config['SESSION_COOKIE_HTTPONLY'] = True
|
||||
app.config['SESSION_COOKIE_SAMESITE'] = 'Lax'
|
||||
|
||||
# Cache directory setup
|
||||
CACHE_DIR = Path('cache')
|
||||
|
||||
@@ -6,6 +6,8 @@ Flask-Compress==1.14
|
||||
Flask-SocketIO==5.3.6
|
||||
Flask-Mail==0.9.1
|
||||
Flask-Migrate==4.0.5
|
||||
Flask-Session==0.5.0
|
||||
redis==5.0.1
|
||||
pandas==2.0.3
|
||||
numpy==1.24.3
|
||||
requests==2.31.0
|
||||
|
||||
Reference in New Issue
Block a user