Your Name 3 years ago
parent
commit
f6bfe24c2c
1 changed files with 17 additions and 6 deletions
  1. 17 6
      step_question/apis/main.py

+ 17 - 6
step_question/apis/main.py

@@ -35,7 +35,7 @@ app.add_middleware(
 )
 
 
-
+coffee=False
 def hhh_send_mail(email,coffee=False):
     SENDER = "Gorgeous Space <noreply@hhh.com.tw>"
     RECIPIENT = "jeweiliang@gmail.com"
@@ -164,12 +164,23 @@ async def line_submit(request: Request):
 
 app.mount("/a1", StaticFiles(directory="static"), name="static")
 
-@app.get("/coffee")
-async def coffee():
-    val=random.randint(5,100)
-    coffee='0'
-    if val%2==0:
+@app.get("/coffee/set/{item_id}")
+async def coffee_set(item_id: int):
+    global coffee
+    if item_id==0:
+        coffee='0'
+    else:
         coffee='1'
+    return {"code":"ok" }
+
+
+@app.get("/coffee")
+async def coffee_get():
+    global coffee
+#    val=random.randint(5,100)
+#    coffee='0'
+#    if val%2==0:
+#        coffee='1'
     return {'coffee':coffee}