steveagi commited on
Commit
52d759d
·
1 Parent(s): e4421b2

add matchn

Browse files
Files changed (2) hide show
  1. main.py +2 -1
  2. routers/matchn.py +37 -0
main.py CHANGED
@@ -1,8 +1,9 @@
1
  from fastapi import FastAPI
2
- from routers import root, snake, watermelon, house
3
 
4
  app = FastAPI()
5
  app.include_router(root.router)
6
  app.include_router(house.router)
7
  app.include_router(watermelon.router)
 
8
  app.include_router(snake.router)
 
1
  from fastapi import FastAPI
2
+ from routers import root, snake, watermelon, house, matchn
3
 
4
  app = FastAPI()
5
  app.include_router(root.router)
6
  app.include_router(house.router)
7
  app.include_router(watermelon.router)
8
+ app.include_router(matchn.router)
9
  app.include_router(snake.router)
routers/matchn.py ADDED
@@ -0,0 +1,37 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from fastapi import APIRouter, Body
2
+ from . import game_util
3
+
4
+
5
+ GAME = "matchn"
6
+ router = APIRouter(prefix=f"/games/{GAME}/nlp", tags=[GAME])
7
+
8
+
9
+
10
+ @router.post("/c")
11
+ def create(code: str=Body(), command: str=Body(), result: list=Body(), desc: list=Body()):
12
+ print(f"[{GAME}]", "c", command, result, desc)
13
+ return game_util.op(GAME, code, "c", command, result, desc)
14
+
15
+
16
+ @router.post("/r")
17
+ def read(code: str=Body(), command: str=Body()):
18
+ print(f"[{GAME}]", "r", command)
19
+ return game_util.op(GAME, code, "r", command)
20
+
21
+
22
+ # @router.post("/u")
23
+ # def update(code: str=Body(), command: str=Body()):
24
+ # print(f"[{GAME}]", "u", command)
25
+ # return game_util.op(GAME, code, "u", command)
26
+
27
+
28
+ @router.post("/d")
29
+ def delete(code: str=Body(), command: str=Body()):
30
+ print(f"[{GAME}]", "d", command)
31
+ return game_util.op(GAME, code, "d", command)
32
+
33
+
34
+ @router.post("/reset")
35
+ def reset(code: str=Body()):
36
+ print(f"[{GAME}]", "d", "reset")
37
+ return game_util.op(GAME, code, "reset", "")