yangtb24 commited on
Commit
9932fa3
1 Parent(s): ae8d22c

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +4 -6
app.py CHANGED
@@ -341,30 +341,28 @@ def get_billing_info():
341
  @app.route('/handsome/v1/dashboard/billing/usage', methods=['GET'])
342
  def billing_usage():
343
  """
344
- 处理 /handsome/v1/dashboard/billing/usage 路由的请求,返回用量信息(模拟)。
345
  """
346
  if not check_authorization(request):
347
  return jsonify({"error": "Unauthorized"}), 401
348
 
349
- # 获取当前时间和30天前的时间
350
  end_date = datetime.now()
351
  start_date = end_date - timedelta(days=30)
352
 
353
- # 构造用量数据(模拟)
354
  daily_usage = []
355
  current_date = start_date
356
  while current_date <= end_date:
357
- # 假设每天的用量是总额度的 1/1000
358
  daily_usage.append({
359
  "timestamp": int(current_date.timestamp()),
360
- "daily_usage": get_billing_info() / 1000
361
  })
362
  current_date += timedelta(days=1)
363
 
364
  return jsonify({
365
  "object": "list",
366
  "data": daily_usage,
367
- "total_usage": sum(day["daily_usage"] for day in daily_usage)
368
  })
369
 
370
  @app.route('/handsome/v1/dashboard/billing/subscription', methods=['GET'])
 
341
  @app.route('/handsome/v1/dashboard/billing/usage', methods=['GET'])
342
  def billing_usage():
343
  """
344
+ 处理 /handsome/v1/dashboard/billing/usage 路由的请求,返回用量信息(修改后,始终返回 0)。
345
  """
346
  if not check_authorization(request):
347
  return jsonify({"error": "Unauthorized"}), 401
348
 
 
349
  end_date = datetime.now()
350
  start_date = end_date - timedelta(days=30)
351
 
352
+ # 构造用量数据(修改后,始终返回 0)
353
  daily_usage = []
354
  current_date = start_date
355
  while current_date <= end_date:
 
356
  daily_usage.append({
357
  "timestamp": int(current_date.timestamp()),
358
+ "daily_usage": 0
359
  })
360
  current_date += timedelta(days=1)
361
 
362
  return jsonify({
363
  "object": "list",
364
  "data": daily_usage,
365
+ "total_usage": 0
366
  })
367
 
368
  @app.route('/handsome/v1/dashboard/billing/subscription', methods=['GET'])