ming před 3 roky
rodič
revize
c8c68b9aaf
1 změnil soubory, kde provedl 2 přidání a 1 odebrání
  1. 2 1
      newbot.py

+ 2 - 1
newbot.py

@@ -144,6 +144,7 @@ async def callback(request: fastapi.Request):
 
 
 @app.get('/get_trend_image')
 @app.get('/get_trend_image')
 async def get_trend_image(kw):
 async def get_trend_image(kw):
+#def get_trend_image(kw):
     db = dataset.connect('mysql://choozmo:pAssw0rd@db.ptt.cx:3306/yodb?charset=utf8mb4')
     db = dataset.connect('mysql://choozmo:pAssw0rd@db.ptt.cx:3306/yodb?charset=utf8mb4')
     sql_get_newest_data_date = 'SELECT * FROM interest_over_time WHERE iot_kword="'+kw+'" ORDER BY iot_date'
     sql_get_newest_data_date = 'SELECT * FROM interest_over_time WHERE iot_kword="'+kw+'" ORDER BY iot_date'
     x_axis = []
     x_axis = []
@@ -163,7 +164,7 @@ async def get_trend_image(kw):
     plt.plot(x, y,'r-^') # 設定樣式
     plt.plot(x, y,'r-^') # 設定樣式
     plt.savefig(target_path, bbox_inches='tight') #存檔,第二個參數表示把圖表外多餘的空間刪除
     plt.savefig(target_path, bbox_inches='tight') #存檔,第二個參數表示把圖表外多餘的空間刪除
     
     
-    return target_path
+    return FileResponse(target_path)
 
 
 
 
 def get_news_by_kw(keyword):
 def get_news_by_kw(keyword):