Your Name 4 years ago
parent
commit
20b8e79571
1 changed files with 14 additions and 0 deletions
  1. 14 0
      apis/newbot.py

+ 14 - 0
apis/newbot.py

@@ -67,6 +67,17 @@ def get_aws():
         result+=str(c['dt'])+"/"+c['area']+"\n"
     return result
 
+
+@app.get("/aws")
+async def aws():
+    result='<html><body><table>'
+    db = dataset.connect('mysql://choozmo:pAssw0rd@db.ptt.cx:3306/hhh?charset=utf8mb4')
+    cursor=db.query('SELECT from_unixtime(eventtime) as dt,area FROM hhh.aws_monitor order by eventtime desc limit 10;')
+    for c in cursor:
+        result+="<tr><td>"+str(c['dt'])+"</td><td>"+c['area']+"</td></tr>\n"
+    result+='</table></body></html>'
+    return result
+
 @app.get("/msg/{item_id}")
 async def coffee_msg(item_id):
     True
@@ -129,6 +140,9 @@ def message_text(event):
         line_bot_api.reply_message(
             event.reply_token,
             TextSendMessage(text=get_aws()))
+        line_bot_api.reply_message(
+            event.reply_token,
+            TextSendMessage(text='完整報告: https://api.ptt.cx:5443/aws'))
         return